From 1ccb9183b4cfcd77f7617a364e74bb8ac037078e Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 19 May 2023 19:57:40 +0000 Subject: [PATCH] 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 --- core/core.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/core.js b/core/core.js index fa5da0bf..53dbe066 100644 --- a/core/core.js +++ b/core/core.js @@ -192,7 +192,9 @@ async function getProcessBlob(blobId, key, options) { process.credentials = options.credentials || {}; process.task = new Task(); process.eventHandlers = {}; - process.app = new app.App(); + if (!options?.script || options?.script === 'app.js') { + process.app = new app.App(); + } process.lastActive = Date.now(); process.lastPing = null; process.timeout = options.timeout; @@ -276,7 +278,7 @@ async function getProcessBlob(blobId, key, options) { throw Error(`Permission denied: ${permission}.`); } - } else { + } else if (process.app) { return process.app.makeFunction(['requestPermission'])(permission).then(function(value) { if (value == 'allow') { storePermission(user, options.packageOwner, options.packageName, permission, true); @@ -293,6 +295,8 @@ async function getProcessBlob(blobId, key, options) { } 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) { try { - process.app.makeFunction(['error'])(error); - } catch(e) { + if (process.app) { + process.app.makeFunction(['error'])(error); + } else { + print(error); + } + } catch (e) { print(e); } };