GeezerVison is showing github.com — src: disable uncaught exception abortion for ESM syntax detection · nodejs/node@709ac47
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_contextify.cc +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1468,6 +1468,7 @@ void ContextifyContext::ContainsModuleSyntax( |
1468 | 1468 | String::NewFromUtf8(isolate, "__dirname").ToLocalChecked()}; |
1469 | 1469 |
|
1470 | 1470 | TryCatchScope try_catch(env); |
| 1471 | + ShouldNotAbortOnUncaughtScope no_abort_scope(env); |
1471 | 1472 |
|
1472 | 1473 | ContextifyContext::CompileFunctionAndCacheResult(env, |
1473 | 1474 | context, |
|
Collapse file
Copy file name to clipboardExpand all lines: test/es-module/test-esm-detect-ambiguous.mjs +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -235,3 +235,23 @@ describe('--experimental-detect-module', { concurrency: true }, () => { |
235 | 235 | } |
236 | 236 | }); |
237 | 237 | }); |
| 238 | + |
| 239 | +// Validate temporarily disabling `--abort-on-uncaught-exception` |
| 240 | +// while running `containsModuleSyntax`. |
| 241 | +// Ref: https://github.com/nodejs/node/issues/50878 |
| 242 | +describe('Wrapping a `require` of an ES module while using `--abort-on-uncaught-exception`', () => { |
| 243 | + it('should work', async () => { |
| 244 | + const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ |
| 245 | + '--abort-on-uncaught-exception', |
| 246 | + '--eval', |
| 247 | + 'assert.throws(() => require("./package-type-module/esm.js"), { code: "ERR_REQUIRE_ESM" })', |
| 248 | + ], { |
| 249 | + cwd: fixtures.path('es-modules'), |
| 250 | + }); |
| 251 | + |
| 252 | + strictEqual(stderr, ''); |
| 253 | + strictEqual(stdout, ''); |
| 254 | + strictEqual(code, 0); |
| 255 | + strictEqual(signal, null); |
| 256 | + }); |
| 257 | +}); |