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

refactor(remix-dev): write build version to version.txt alongside the server build #7299

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/pretty-ears-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

internal: write a version.txt sentinel file _after_ server build is completely written
12 changes: 11 additions & 1 deletion packages/remix-dev/compiler/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as fs from "node:fs";
import * as path from "node:path";

import type { Context } from "./context";
Expand Down Expand Up @@ -119,7 +120,16 @@ export let create = async (ctx: Context): Promise<Compiler> => {
let server = await tasks.server;
if (!server.ok) throw error ?? server.error;
// artifacts/server
writes.server = Server.write(ctx.config, server.value);
writes.server = Server.write(ctx.config, server.value).then(() => {
// write the version to a sentinel file _after_ the server has been written
// this allows the app server to watch for changes to `version.txt`
// avoiding race conditions when the app server would attempt to reload a partially written server build
let versionTxt = path.join(
path.dirname(ctx.config.serverBuildPath),
"version.txt"
);
fs.writeFileSync(versionTxt, manifest.version);
});

await Promise.all(Object.values(writes));
return manifest;
Expand Down