GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — esm: fix missed renaming in ModuleJob.runSync · nodejs/node@dbe6e63

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/modules/esm
    • module_job.js
  • test
    • es-module
      • test-import-require-tla-twice.js
    • fixtures/es-modules/import-require-tla-twice
      • hook.js
      • require-tla.js
      • tla.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/modules/esm/module_job.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/module_job.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class ModuleJob extends ModuleJobBase {
335335
const parentFilename = urlToFilename(parent?.filename);
336336
this.module.hasAsyncGraph ??= this.module.isGraphAsync();
337337

338-
if (this.module.async && !getOptionValue('--experimental-print-required-tla')) {
338+
if (this.module.hasAsyncGraph && !getOptionValue('--experimental-print-required-tla')) {
339339
throw new ERR_REQUIRE_ASYNC_MODULE(filename, parentFilename);
340340
}
341341
if (status === kInstantiated) {
Collapse file

‎test/es-module/test-import-require-tla-twice.js‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
// This tests that in the require() in imported CJS can retry loading an ESM with TLA
3+
// twice and get the correct error both times.
4+
5+
require('../common');
6+
const { spawnSyncAndAssert } = require('../common/child_process');
7+
const fixtures = require('../common/fixtures');
8+
const assert = require('assert');
9+
10+
spawnSyncAndAssert(
11+
process.execPath,
12+
['--import', fixtures.fileURL('es-modules', 'import-require-tla-twice', 'hook.js'),
13+
fixtures.path('es-modules', 'import-require-tla-twice', 'require-tla.js'),
14+
],
15+
{
16+
stdout(output) {
17+
const matches = output.matchAll(/e\.code === ERR_REQUIRE_ASYNC_MODULE true/g);
18+
assert.strictEqual([...matches].length, 2);
19+
}
20+
}
21+
);
Collapse file

‎test/fixtures/es-modules/import-require-tla-twice/hook.js‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { registerHooks } = require('module');
2+
registerHooks({
3+
load(url, context, nextLoad) {
4+
return nextLoad(url, context);
5+
}
6+
});
Collapse file

‎test/fixtures/es-modules/import-require-tla-twice/require-tla.js‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
try {
2+
require('./tla.mjs');
3+
} catch (e) {
4+
console.log('e.code === ERR_REQUIRE_ASYNC_MODULE', e.code === 'ERR_REQUIRE_ASYNC_MODULE');
5+
}
6+
7+
try {
8+
require('./tla.mjs');
9+
} catch (e) {
10+
console.log('e.code === ERR_REQUIRE_ASYNC_MODULE', e.code === 'ERR_REQUIRE_ASYNC_MODULE');
11+
}
Collapse file

‎test/fixtures/es-modules/import-require-tla-twice/tla.mjs‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
await Promise.resolve('1');

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.