Skip to content

Commit df7e71d

Browse files
fix(builders): harden Windows HMR file writes (#2853)
1 parent 9958424 commit df7e71d

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

.changeset/bright-cycles-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@workflow/builders': patch
3+
---
4+
5+
Use the Windows-safe generated-file writer for step registration output.

packages/builders/src/base-builder.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,7 @@ ${importStatements.join('\n')}
902902
export const __steps_registered = true;
903903
`;
904904
await mkdir(dirname(outfile), { recursive: true });
905-
const tempPath = `${outfile}.${randomUUID()}.tmp`;
906-
await writeFile(tempPath, output);
907-
await rename(tempPath, outfile);
905+
await this.writeGeneratedFile(outfile, output);
908906

909907
const manifestFiles = Array.from(
910908
new Set([...stepFiles, ...serdeOnlyFiles, resolvedBuiltInSteps])

packages/core/e2e/dev.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export function createDevTests(config?: DevTestConfig) {
8282
: process.platform === 'win32'
8383
? 140_000
8484
: 70_000;
85+
const multiPhaseHmrTestTimeoutMs =
86+
hmrTestTimeoutMs + hmrRediscoveryTimeoutMs;
8587
const flowRouteHmrFuzzTimeoutMs = finalConfig.canary ? 480_000 : 240_000;
8688
const readManifestStepFunctionNames = async (): Promise<string[]> => {
8789
const manifestJson = await fs.readFile(workflowManifestPath, 'utf8');
@@ -458,7 +460,11 @@ export async function hmrPageWorkflow() {
458460

459461
test(
460462
'should rebuild on workflow change',
461-
{ timeout: hmrTestTimeoutMs },
463+
{
464+
timeout: usesNextFlowRoute
465+
? multiPhaseHmrTestTimeoutMs
466+
: hmrTestTimeoutMs,
467+
},
462468
async () => {
463469
if (usesNextFlowRoute) {
464470
await waitForHmrReady();
@@ -491,7 +497,7 @@ ${apiFileContent}`
491497
);
492498
await pollUntil({
493499
description: 'workflow-change fixture to appear in manifest',
494-
timeoutMs: 50_000,
500+
timeoutMs: hmrRediscoveryTimeoutMs,
495501
check: async () => {
496502
await prewarm();
497503
expect(await readManifestWorkflowFunctionNames()).toContain(
@@ -517,7 +523,7 @@ export async function myNewWorkflow() {
517523

518524
await pollUntil({
519525
description: 'generated workflow to include myNewWorkflow',
520-
timeoutMs: usesNextFlowRoute ? 50_000 : 25_000,
526+
timeoutMs: usesNextFlowRoute ? hmrRediscoveryTimeoutMs : 25_000,
521527
check: async () => {
522528
if (usesNextFlowRoute) {
523529
await prewarm();
@@ -717,7 +723,7 @@ ${apiFileContent}`
717723

718724
await pollUntil({
719725
description: 'generated workflow to include newWorkflowFile',
720-
timeoutMs: 50_000,
726+
timeoutMs: hmrRediscoveryTimeoutMs,
721727
check: async () => {
722728
if (usesNextFlowRoute) {
723729
const manifestJson = await fs.readFile(

0 commit comments

Comments
 (0)