@webqit/webflo 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -78,15 +78,17 @@ export class WebfloRouter {
|
|
|
78
78
|
thisTick.event.onRespondWith = null;
|
|
79
79
|
res(response);
|
|
80
80
|
};
|
|
81
|
-
const $returnValue = handler.call(thisContext, thisTick.event, thisTick.arg, _next/*next*/, remoteFetch);
|
|
81
|
+
const $returnValue = Promise.resolve(handler.call(thisContext, thisTick.event, thisTick.arg, _next/*next*/, remoteFetch));
|
|
82
|
+
// This should listen first before waitUntil's listener
|
|
83
|
+
$returnValue.then(async (returnValue) => {
|
|
84
|
+
if (thisTick.event.onRespondWith) {
|
|
85
|
+
thisTick.event.onRespondWith = null;
|
|
86
|
+
res(returnValue);
|
|
87
|
+
} else if (typeof returnValue !== 'undefined') {
|
|
88
|
+
await thisTick.event.respondWith(returnValue);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
82
91
|
thisTick.event.waitUntil($returnValue);
|
|
83
|
-
const returnValue = await $returnValue;
|
|
84
|
-
if (thisTick.event.onRespondWith) {
|
|
85
|
-
thisTick.event.onRespondWith = null;
|
|
86
|
-
res(returnValue);
|
|
87
|
-
} else if (typeof returnValue !== 'undefined') {
|
|
88
|
-
await thisTick.event.respondWith(returnValue);
|
|
89
|
-
}
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
// Handler not found but exports found
|
|
@@ -397,13 +397,10 @@ export class WebfloClient extends WebfloRuntime {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
Promise.all([...scope.eventLifecyclePromises]).then(() => {
|
|
400
|
-
if (scope.clientMessaging.isMessaging()) {
|
|
401
|
-
scope.
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}, 100);
|
|
405
|
-
});
|
|
406
|
-
} else scope.clientMessaging.close();
|
|
400
|
+
if (!scope.clientMessaging.isMessaging()) {
|
|
401
|
+
// DOn't clos the below; think the below: scope.httpEvent.client.postMessage()
|
|
402
|
+
//scope.clientMessaging.close();
|
|
403
|
+
}
|
|
407
404
|
});
|
|
408
405
|
// ---------------
|
|
409
406
|
// Decode response
|
|
@@ -487,8 +487,8 @@ export class WebfloServer extends WebfloRuntime {
|
|
|
487
487
|
scope.eventLifecyclePromises.dirty = true;
|
|
488
488
|
promise.then(() => scope.eventLifecyclePromises.delete(promise));
|
|
489
489
|
},
|
|
490
|
-
respondWith: async (response) => {
|
|
491
|
-
if (scope.eventLifecyclePromises.dirty && !scope.eventLifecyclePromises.size) {
|
|
490
|
+
respondWith: async (response, isRedirectMessage = false) => {
|
|
491
|
+
if (!isRedirectMessage && scope.eventLifecyclePromises.dirty && !scope.eventLifecyclePromises.size) {
|
|
492
492
|
throw new Error('Final response already sent');
|
|
493
493
|
}
|
|
494
494
|
return await this.execPush(scope.clientMessaging, response);
|
|
@@ -546,7 +546,7 @@ export class WebfloServer extends WebfloRuntime {
|
|
|
546
546
|
this.writeRedirectHeaders(scope.httpEvent, scope.response);
|
|
547
547
|
} else {
|
|
548
548
|
if (scope.redirectMessage) {
|
|
549
|
-
scope.eventLifecycleHooks.respondWith(scope.redirectMessage);
|
|
549
|
+
scope.eventLifecycleHooks.respondWith(scope.redirectMessage, true);
|
|
550
550
|
}
|
|
551
551
|
this.writeAutoHeaders(scope.response.headers, scope.autoHeaders.filter((header) => header.type === 'response'));
|
|
552
552
|
if (scope.httpEvent.request.method !== 'GET' && !scope.response.headers.get('Cache-Control')) {
|