Skip to content

fix(esm): dont bail for preflight requests#39237

Open
Skn0tt wants to merge 1 commit intomicrosoft:mainfrom
Skn0tt:dont-bail-for-preflight
Open

fix(esm): dont bail for preflight requests#39237
Skn0tt wants to merge 1 commit intomicrosoft:mainfrom
Skn0tt:dont-bail-for-preflight

Conversation

@Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Feb 12, 2026

Closes #39172.

Interestingly, the test without the fix immediately leads to the Error: duplicate test title "another test", first declared in example.spec.ts.esm.preflight:13 bug, so we have a good repro even without tsx. It seems to affect any loader.

@Skn0tt Skn0tt requested a review from dgozman February 12, 2026 09:07
@Skn0tt Skn0tt self-assigned this Feb 12, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

}

const code = fs.readFileSync(filename, 'utf-8');
const transformed = transformHook(code, filename, moduleUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd skip this for preflights that we want to bail on, e.g. from node_modules. Since we are not supposed to transform them, we don't need to prepopulate source mapes.

I'd make a custom defaultLoad function that would return void 0 for preflights or call the actual defaultLoad for non-preflights.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't like the custom defaultLoad function, but I found a different way of writing it that skips the fs ops and transform for preflights, and looks pretty readable.

@github-actions

This comment has been minimized.

@Skn0tt Skn0tt force-pushed the dont-bail-for-preflight branch from 7fafc93 to be4648f Compare February 12, 2026 14:56
@github-actions
Copy link
Contributor

Test results for "tests 1"

14 failed
❌ [playwright-test] › expect-poll.spec.ts:105 › should fail when used with web-first assertion @macos-latest-node20
❌ [playwright-test] › expect.spec.ts:508 › should support toHaveURL with baseURL from webServer @macos-latest-node20
❌ [playwright-test] › expect.spec.ts:562 › should support toHaveURL predicate @macos-latest-node20
❌ [playwright-test] › expect.spec.ts:582 › should log scale the time @macos-latest-node20
❌ [playwright-test] › playwright.spec.ts:877 › page.pause() should disable test timeout @macos-latest-node20
❌ [playwright-test] › playwright.trace.spec.ts:137 › should not throw with trace: on-first-retry and two retries in the same worker @macos-latest-node20
❌ [playwright-test] › reporter-markdown.spec.ts:158 › report with annotations @macos-latest-node20
❌ [playwright-test] › reporter.spec.ts:251 › created › should not have internal error when steps are finished after timeout @macos-latest-node20
❌ [playwright-test] › reporter.spec.ts:251 › merged › should not have internal error when steps are finished after timeout @macos-latest-node20
❌ [playwright-test] › esm.spec.ts:150 › should use source maps @ubuntu-latest-node24
❌ [playwright-test] › esm.spec.ts:264 › should filter by line @ubuntu-latest-node24
❌ [playwright-test] › update-aria-snapshot.spec.ts:669 › update-source-method › should overwrite source when specified in the config @macos-latest-node20
❌ [playwright-test] › watch.spec.ts:500 › should run on changed deps in ESM @ubuntu-latest-node24
❌ [playwright-test] › watch.spec.ts:772 › should run CT on indirect deps change ESM mode @ubuntu-latest-node24

2 flaky ⚠️ [chromium-library] › library/popup.spec.ts:258 › should not throw when click closes popup `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/popup.spec.ts:258 › should not throw when click closes popup `@chromium-ubuntu-22.04-node24`

38514 passed, 843 skipped


Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "MCP"

5 failed
❌ [chrome] › mcp/roots.spec.ts:47 › check that trace is saved in workspace @mcp-windows-latest
❌ [chromium] › mcp/tracing.spec.ts:21 › check that trace is saved with --save-trace @mcp-windows-latest
❌ [chrome] › mcp/video.spec.ts:43 › should work with { saveVideo } (isolated) @mcp-macos-15
❌ [chromium] › mcp/cli-save-as.spec.ts:19 › screenshot @mcp-macos-15
❌ [chromium] › mcp/launch.spec.ts:21 › test reopen browser @mcp-macos-15

4787 passed, 135 skipped


Merge workflow run.

moduleUrl = moduleUrl.replace(esmPreflightExtension, '');
const filename = url.fileURLToPath(moduleUrl);
const format = kSupportedFormats.get(context.format) || (fileIsModule(filename) ? 'module' : 'commonjs');
if (isPreflight)
Copy link
Contributor

Choose a reason for hiding this comment

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

This always skips transformHook which is the sole purpose of having a preflight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Playwright 1.58.0 collects *.esm.preflight files as tests, causing duplicate test title errors

2 participants