Create the local persisted queries file when it is missing - #5388
Open
GregoryCollett wants to merge 1 commit into
Open
Create the local persisted queries file when it is missing#5388GregoryCollett wants to merge 1 commit into
GregoryCollett wants to merge 1 commit into
Conversation
With `persistConfig.file`, the compiler previously refused to start if
the file did not exist ("The file `...` for the local query persisting
does not exist"), even though the file is a compiler output. On fresh
checkouts and in CI the file never exists, forcing projects to commit a
stub map or wrap the compiler in a script that pre-creates one.
- PersistConfig deserialization no longer requires the file to exist
(this also removes filesystem access from Deserialize, which resolved
the path against the process cwd rather than the config location).
- LocalPersister::new treats a missing file as an empty query map;
other read errors now surface the underlying io error.
- LocalPersister::finalize creates missing parent directories, the same
way the artifact writer does for artifacts.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
persistConfiguses the local file mode, the compiler refuses to start if the configured file does not exist:But this file is a compiler output — the docs describe the feature as "you can generate a local JSON file which contains a map of
operation_id => full operation text". Because it's a build artifact it is typically gitignored, so the compiler only starts on machines where a previous run happens to have left the file behind. On a fresh checkout — i.e. every CI run — it errors out until you either commit a stub{}map or wrap every compiler invocation in a script that pre-creates the file. (It's the single-file analogue of committing a.gitkeepto satisfy theartifactDirectorycheck.)The check also lives inside
Deserialize for PersistConfig, so it performs filesystem I/O during config parsing and resolves the path against the process cwd rather than the config file's location.Changes
PersistConfigdeserialization no longer requires the local file to exist (and no longer touches the filesystem).LocalPersister::newtreats a missing file as an empty query map (the first-run state). Other read errors still panic, but the message now includes the underlying io error instead of claiming the file must exist.LocalPersister::finalizecreates missing parent directories before writing, matching what the artifact writer does for artifacts.PersistConfig::Localupdated accordingly andrelay-compiler-config-schema.jsonregenerated.Behaviour notes
persisted_queries_file_existing_entries_preservedfixture, whose snapshot is byte-identical with and without the code change.filepath now results in the map being written at the typo'd path instead of a startup error — i.e. ordinary build-output (mkdir -p) semantics.--repersistalready exists to force a full re-persist. That outcome is identical to today's stub-file workaround; this PR just removes the need for the workaround.Tests
Three new integration fixtures:
persisted_queries_file_created_when_missing— the main repro. Before the fix this snapshotted the startup error; now the compiler runs and the snapshot showspersisted_queries.jsonbeing created alongside the artifact.persisted_queries_file_existing_entries_preserved— pins the pre-existing merge behaviour (snapshot unchanged by the fix).persisted_queries_file_missing_parent_directories_created—"file": "./persisted/queries.json"with nopersisted/directory in the fixture.cargo test --lockedfor the workspace passes locally apart fromserver_daemon::tests::test_status_stale_when_socket_file_exists_but_no_listener, which on my machine fails under the parallel lib test run and passes in isolation, both with and without this change (pre-existing, unrelated).Also verified end-to-end against our application's single-project
relay.config.jsonwith the persist file absent: previously failed at startup, now compiles and writes the populated map.