Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fixes an issue where using "node:test" results in infinite loop #27685

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ const defaultNpmResolutionCache: NpmResolutionCache = new Map();
const builtInModuleSet = new Set<string>([
...builtinModules,
...builtinModules.map((x) => `node:${x}`),
// These are missing in the builtinModules list
// See: https://github.com/nodejs/node/issues/42785
// TODO(v20): We should be safe to use `isBuiltin` function instead of keep the set here (https://nodejs.org/api/module.html#moduleisbuiltinmodulename)
'test',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a unit test for test and node:test.

Can you add sqlite and sea while you're at it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, node:sea exists, sea does not so I'll add the former.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with node:sqlite.

'node:test',
'node:sea',
'node:sqlite',
]);

export function isBuiltinModuleImport(importExpr: string): boolean {
Expand Down Expand Up @@ -364,7 +371,7 @@ export class TargetProjectLocator {
packageJsonPath ?? resolveRelativeToDir(packageName, relativeToDir);
let dir = dirname(pathOfFileInPackage);

while (dir !== parse(dir).root) {
while (dir !== dirname(dir)) {
const packageJsonPath = join(dir, 'package.json');
try {
const parsedPackageJson = readJsonFile(packageJsonPath);
Expand Down