Unverified Commit a9a3098c authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

[devlow-bench] fail with non-zero exit and restore file.js (#69116)

devlow-bench regressed, and it went unnoticed since the cli simply
logged a stack and exited the process normally [0], so CI continued
passing. This corrects that by exiting the process with a non-zero code.

This also fixes the cause of the regression, where `file.js` was not
brought over during the repo merge.

Test Plan: devlow-bench job in CI.

[0]
https://github.com/vercel/next.js/blob/cc484b996ad235c4a5acc284c099c2d5cab8c72d/turbopack/packages/devlow-bench/src/cli.ts#L112-L114
parent f94c6032
......@@ -111,4 +111,5 @@ import { pathToFileURL } from "url";
await runScenarios(scenarios, compose(...ifaces));
})().catch((e) => {
console.error(e.stack);
process.exit(1);
});
import { watch } from 'fs'
import { access, constants } from 'fs/promises'
import { dirname } from 'path'
export async function waitForFile(
path: string,
timeout: number
): Promise<void> {
let currentAction = ''
let timeoutRef
const timeoutPromise = new Promise<void>((resolve, reject) => {
timeoutRef = setTimeout(() => {
reject(
new Error(`Timed out waiting for file ${path} (${currentAction}))`)
)
}, timeout || 60000)
})
const elements: string[] = []
let current = path
while (true) {
elements.push(current)
const parent = dirname(current)
if (parent === current) {
break
}
current = parent
}
elements.reverse()
try {
for (const path of elements) {
const checkAccess = () =>
access(path, constants.F_OK)
.then(() => true)
.catch(() => false)
if (!(await checkAccess())) {
let resolveCheckAgain = () => {}
const watcher = watch(dirname(path), () => {
resolveCheckAgain()
})
currentAction = `waiting for ${path}`
let checkAgainPromise = new Promise<void>((resolve) => {
resolveCheckAgain = resolve
})
try {
do {
await Promise.race([timeoutPromise, checkAgainPromise])
// eslint-disable-next-line no-loop-func
checkAgainPromise = new Promise<void>((resolve) => {
resolveCheckAgain = resolve
})
} while (!(await checkAccess()))
} finally {
watcher.close()
}
}
}
} finally {
clearTimeout(timeoutRef)
}
}
import picocolors from "picocolors";
import { Interface } from "../index.js";
import { bgCyan, bold, magenta, red, underline } from "picocolors";
import { formatUnit } from "../units.js";
import { formatVariant } from "../utils.js";
const { bgCyan, bold, magenta, red, underline } = picocolors;
export default function createInterface(): Interface {
const iface: Interface = {
start: async (scenario, props) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment