| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 683cc15 commit 5665e86
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -215,8 +215,6 @@ async function customizedModuleWorker(lock, syncCommPort, errorHandler) { | |||
| 215 | 215 | (port ?? syncCommPort).postMessage(wrapMessage('error', exception)); | |
| 216 | 216 | } | |
| 217 | 217 | ||
| 218 | - AtomicsAdd(lock, WORKER_TO_MAIN_THREAD_NOTIFICATION, 1); | ||
| 219 | - AtomicsNotify(lock, WORKER_TO_MAIN_THREAD_NOTIFICATION); | ||
| 220 | 218 | if (shouldRemoveGlobalErrorHandler) { | |
| 221 | 219 | process.off('uncaughtException', errorHandler); | |
| 222 | 220 | } | |
@@ -225,6 +223,10 @@ async function customizedModuleWorker(lock, syncCommPort, errorHandler) { | |||
| 225 | 223 | // We keep checking for new messages to not miss any. | |
| 226 | 224 | clearImmediate(immediate); | |
| 227 | 225 | immediate = setImmediate(checkForMessages).unref(); | |
| 226 | + // To prevent the main thread from terminating before this function completes after unlocking, | ||
| 227 | + // the following process is executed at the end of the function. | ||
| 228 | + AtomicsAdd(lock, WORKER_TO_MAIN_THREAD_NOTIFICATION, 1); | ||
| 229 | + AtomicsNotify(lock, WORKER_TO_MAIN_THREAD_NOTIFICATION); | ||
| 228 | 230 | } | |
| 229 | 231 | } | |
| 230 | 232 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -285,4 +285,20 @@ describe('Loader hooks parsing modules', { concurrency: !process.env.TEST_PARALL | |||
| 285 | 285 | assert.strictEqual(code, 0); | |
| 286 | 286 | assert.strictEqual(signal, null); | |
| 287 | 287 | }); | |
| 288 | + | ||
| 289 | + it('throw maximum call stack error on the loader', async () => { | ||
| 290 | + const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
| 291 | + '--no-warnings', | ||
| 292 | + '--experimental-loader', | ||
| 293 | + fixtures.fileURL('/es-module-loaders/hooks-custom.mjs'), | ||
| 294 | + '--input-type=module', | ||
| 295 | + '--eval', | ||
| 296 | + 'await import("esmHook/maximumCallStack.mjs")', | ||
| 297 | + ]); | ||
| 298 | + | ||
| 299 | + assert(stderr.includes('Maximum call stack size exceeded')); | ||
| 300 | + assert.strictEqual(stdout, ''); | ||
| 301 | + assert.strictEqual(code, 1); | ||
| 302 | + assert.strictEqual(signal, null); | ||
| 303 | + }); | ||
| 288 | 304 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,5 +105,12 @@ export function load(url, context, next) { | |||
| 105 | 105 | }; | |
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | + if (url.endsWith('esmHook/maximumCallStack.mjs')) { | ||
| 109 | + function recurse() { | ||
| 110 | + recurse(); | ||
| 111 | + } | ||
| 112 | + recurse(); | ||
| 113 | + } | ||
| 114 | + | ||
| 108 | 115 | return next(url); | |
| 109 | 116 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments