Don't mess with websockets when we're returning a document from an app's handler.js.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4307 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-05-19 19:57:40 +00:00
parent 7d9b627f37
commit 1ccb9183b4

View File

@ -192,7 +192,9 @@ async function getProcessBlob(blobId, key, options) {
process.credentials = options.credentials || {}; process.credentials = options.credentials || {};
process.task = new Task(); process.task = new Task();
process.eventHandlers = {}; process.eventHandlers = {};
process.app = new app.App(); if (!options?.script || options?.script === 'app.js') {
process.app = new app.App();
}
process.lastActive = Date.now(); process.lastActive = Date.now();
process.lastPing = null; process.lastPing = null;
process.timeout = options.timeout; process.timeout = options.timeout;
@ -276,7 +278,7 @@ async function getProcessBlob(blobId, key, options) {
throw Error(`Permission denied: ${permission}.`); throw Error(`Permission denied: ${permission}.`);
} }
} else { } else if (process.app) {
return process.app.makeFunction(['requestPermission'])(permission).then(function(value) { return process.app.makeFunction(['requestPermission'])(permission).then(function(value) {
if (value == 'allow') { if (value == 'allow') {
storePermission(user, options.packageOwner, options.packageName, permission, true); storePermission(user, options.packageOwner, options.packageName, permission, true);
@ -293,6 +295,8 @@ async function getProcessBlob(blobId, key, options) {
} }
throw Error(`Permission denied: ${permission}.`); throw Error(`Permission denied: ${permission}.`);
}); });
} else {
throw Error(`Permission denied: ${permission}.`);
} }
}, },
} }
@ -353,8 +357,12 @@ async function getProcessBlob(blobId, key, options) {
}; };
process.task.onError = function(error) { process.task.onError = function(error) {
try { try {
process.app.makeFunction(['error'])(error); if (process.app) {
} catch(e) { process.app.makeFunction(['error'])(error);
} else {
print(error);
}
} catch (e) {
print(e); print(e);
} }
}; };