-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
test(fixture): improve finding ports to reduce flaky #55151
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import path from 'path' | |
import spawn from 'cross-spawn' | ||
import { writeFile } from 'fs-extra' | ||
import getPort from 'get-port' | ||
import { getRandomPort } from 'get-port-please' | ||
import fetch from 'node-fetch' | ||
import qs from 'querystring' | ||
import treeKill from 'tree-kill' | ||
|
@@ -171,7 +172,18 @@ export function renderViaHTTP( | |
} | ||
|
||
export function findPort() { | ||
return getPort() | ||
// [NOTE] What are we doing here? | ||
// There are some flaky tests failures caused by `No available ports found` from 'get-port'. | ||
// This may be related / fixed by upstream https://github.com/sindresorhus/get-port/pull/56, | ||
// however it happened after get-port switched to pure esm which is not easy to adapt by bump. | ||
// get-port-please seems to offer the feature parity so we'll try to use it, and leave get-port as fallback | ||
// for a while until we are certain to switch to get-port-please entirely. | ||
try { | ||
return getRandomPort() | ||
} catch (e) { | ||
require('console').warn('get-port-please failed, falling back to get-port') | ||
return getPort() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any reason why we need to fallback to Furthermore, IMHO we should drop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fallback is not meant to stay permanent, we will observe stability and eventually get rid of it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kwonoj That makes sense. IMHO you should add a TODO comment here if it is not meant to be permanent. |
||
} | ||
} | ||
|
||
export interface NextOptions { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work with the latest
get-port
versionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of the box I mean, using our next.js setup. How did you make it work with existing test setup? You can see our test setup doesn't like native esm like
https://github.com/vercel/next.js/actions/runs/6126906741/job/16631841436?pr=55153#step:29:1292
Course could dig further and trying to bend / adjust our setup, but honestly don't feel worth investment unless we want to switch full native esm module support. Probably need to update jest config, and other module resolution including typescript to make it work fully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm guessing jest needs to be configured https://jestjs.io/docs/ecmascript-modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, done it once in other codebases. overall, jest & others + native esm wasn't very pleasant experiences yet, and get-port is native esm only (doesn't provide cjs compat at all) unfortunately.