Repository navigation
feat(cli)!: prisma dev no longer starts the Alchemy CLI; it applies your app, and each edit to it, in a worker thread of its own process - #411
Conversation
Every alchemy pin is now https://pkg.alchemy.run/alchemy/972f294ae0c7982a8ebcb551fadd07d29c9c0fca, and effect with every @effect/* companion is 4.1.0, which that build needs as its peer. The build is 2.0.0-beta.84 plus later commits. What changed for us: - The Prisma provider moved out of alchemy into @alchemy.run/prisma, pinned at the same commit. Imports of alchemy/Prisma now use it. - @distilled.cloud/prisma is pinned to the exact tarball @alchemy.run/prisma depends on, so there is one copy. - alchemy/Test/Core moved to @alchemy.run/test, which is not published. Provider tests use scratchStack and runScratch from the new @internal/lowering/testing entry, a port of the parts we used. - Prisma.CustomDomain now waits for the CNAME on real nameservers before it registers a domain; the public URL test stubs node:dns/promises. - Alchemy has a new --adopt message for replacements; withComposerAdvice rewrites it. check:npm-effect-resolution now also asserts a single alchemy in the npm tree. The upgrade-alchemy-effect skill explains how to pin a preview build. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…slice 1 review - check:publish-deps fails on a URL, git or file: dependency in a published package, and says to swap a pkg.alchemy.run preview for a release. It runs only in the publish workflow, so PR CI is unaffected. - alchemy, @alchemy.run/prisma, @distilled.cloud/prisma, effect and the @effect/platform-* packages are pinned once, in the pnpm catalog. - check:npm-effect-resolution also asserts one @alchemy.run/prisma and one @distilled.cloud/prisma; its comments describe the current peers. - @prisma/composer drops @effect/sql-d1, @effect/sql-sqlite-do and @effect/vitest, which alchemy no longer needs. - @internal/lowering/testing is now @internal/lowering/scratch-stack, and the scratch stack no longer takes a state it ignored. - withComposerAdvice rewrites the Prisma provider's adoption advice too, and a test scans the provider sources for it. - The DNS stub keeps the rest of node:dns/promises. ADR-0048 and the deploying guide are updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…aluation-5f1d17 Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> # Conflicts: # docs/design/90-decisions/README.md # packages/1-prisma-cloud/0-lowering/local-target/src/compute.ts # packages/9-public/composer/package.json # pnpm-lock.yaml # test/integration/package.json
prisma deploy and the deploy operation now lower the app and call Alchemist.plan and Alchemist.apply in process. No alchemy.run.ts is written and no Alchemy child is spawned. destroy and prisma dev keep the stack file. - lower() takes containers and preflight payloads as values; extensions read their payload as LowerContext.preflight. The env transports stay for the stack file. - The report hook returns the summary as a value. - Alchemy events become apply-resource steps under deploy.apply; log lines become messages. - Failures are DEPLOY.ENGINE_FAILED with the cause; Ctrl-C is DEPLOY.INTERRUPTED and closes the scope, releasing the lease. - prisma deploy needs PRISMA_SERVICE_TOKEN in the environment (DEPLOY.SERVICE_TOKEN_REQUIRED): cli-engine 0.9.0 has no public way to hand a command the active access token. - convergeInProcess is the function slice 3 (dev) reuses. - scratch-stack test harness rebuilt on alchemy/Alchemist. - ADR-0064 supersedes ADR-0007 for deploy; amends ADR-0038/0043/0044. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…state - Load lower and convergeInProcess from the app's own @prisma/composer (new @prisma/composer/internal/converge entry), resolved from the app directory; DEPS.ENGINE_UNRESOLVABLE when it cannot be loaded. - lower() takes containers and preflight payloads as required values; transportedLowerInputs() reads both transports for the generated stack files. Core invariant 4 pins process.env to that helper. - convergeInProcess refuses a second concurrent run (DEPLOY.CONVERGE_RUNNING) and a worker thread that would need chdir (DEPLOY.WORKER_THREAD); every process state change is inside the try; Alchemy interaction output goes to stderr; it takes the operation and returns typed failure reasons. - The console redirect moved to the prisma deploy command. - Messages, the engine failure and stack-building errors are redacted. - The service-token check moved into the operation, before preflight and ensure. The command passes a token only for an environment credential, with that credential's workspace, and PRISMA_WORKSPACE_ID is removed when it names none. credentials carries the token; convergeEnv is gone. - family/converge.ts is now family/dev-converge-child.ts. - Docs: ADR-0044 registry, ADR-0064, ADR-0043, ADR-0049, ADR-0062, build-reporting.md, deploy-cli.md and the deploying guide. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
- Rename the app-loaded pair to AppConverge / loadAppConverge and the code to DEPS.CONVERGE_UNRESOLVABLE; add "converge" to the glossary. - loadAppConverge refuses an app @prisma/composer at a version other than the host's (DEPS.CONVERGE_VERSION_MISMATCH, naming both), and resolves the install from the directory of prisma.config.ts. - A rejected converge promise is DEPLOY.ENGINE_FAILED. - The one-converge-per-process flag lives on globalThis under a Symbol.for key, so every install shares it. - withProcessState restores the environment before the directory, and the running flag is set inside the try that clears it. - An interrupted prisma deploy reports DEPLOY.INTERRUPTED as a message and ends with the engine abort, so it exits 130. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…on a failed chdir - @prisma/composer/internal/converge-contract exports CONVERGE_CONTRACT; loadAppConverge reads it before loading the converge and refuses a different number with DEPS.CONVERGE_CONTRACT_MISMATCH, naming both contracts and both versions and saying which side to upgrade. Package versions may differ. - A failed chdir back to a removed directory no longer replaces the converge outcome. - ADR-0064, ADR-0044, the ADR index, deploy-cli.md, the glossary and the deploying guide follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ocess prisma dev, and the dev operation, now lower the app against the local target and run Alchemy's plan and apply in the prisma process, for the first converge and every rebuild. No .prisma-composer/dev/<env>/alchemy.run.ts is written and no Alchemy child is spawned. destroy keeps the child. - The app's @prisma/composer/internal/converge also exports localTargetProviders and devState; CONVERGE_CONTRACT is 2. - Each converge has its own scope, so the state lease is held only while it runs. Rebuilds stay one at a time and coalesce. - Converge progress reaches the user as converge-resource and converge-message dev events; prisma dev renders them as steps and messages, with console stdout sent to stderr for the session. - A failed first converge is DEV.CONVERGE_FAILED with the reasons; a failed rebuild is a converge-failed event with the cause, keeping the app. No stack file path or reproduce command. - DevInput.signal interrupts a running converge: the first one fails with DEV.INTERRUPTED (prisma dev exits 130); stop() interrupts a rebuild's converge and waits for it before stopping services. - The app is imported once per process, so an edit to the entry module or a service's authoring module is reported (definition-changed) and rebuilds pause until dev restarts. - Deleted generate-dev-stack.ts, family/dev-converge-child.ts, the orphaned fake-child fixture, and renderDevStackFile from the testing entry. DEV.STACK_WRITE_FAILED becomes DEV.STATE_WRITE_FAILED. - ADR-0064 extended to dev; deploy-cli.md, local-dev.md, guides, the skill and the amended ADRs updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…steps, dev codes - dev records every app file (outside node_modules) the entry import loaded: under Node through the existing resolve hook (observe only), under Bun from the modules require.cache gained, which includes ES modules. A Bun.plugin onResolve sees only dynamic imports, so it is not used. These app definition files, plus each authoring module, are hashed and watched; an edit to any of them is definition-changed. - One step tracker and one converge-event mapper for deploy and dev. Each dev converge is a step (dev.converge, dev.rebuild.<n>) with its resources inside it, and every step it opened is closed when it ends. - A refused dev converge is DEV.CONVERGE_RUNNING or DEV.WORKER_THREAD, on the first converge and in a rebuild's converge-failed event. - DEV.STATE_WRITE_FAILED is DEV.ENVIRONMENT_WRITE_FAILED. - stop() waits only for a running converge; a rebuild still in its pipeline returns before converging. - CONVERGE_CONTRACT stays 1: contract 1 was never published. - The store integration test edits a sub-module's module.ts while dev runs and checks for the restart notice and that nothing converges. - Docs use "app definition files" throughout; running-locally.md no longer overstates or understates what is detected. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
✅ Gizmo reviewed f5ebd8a — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughThis delta refines how Worker/main-thread split (dev-converge-worker.ts, execute-dev.ts:232-239) — the old code mutated Detection refinement (entry-resolution.ts:102-105) — the error-chain walk was extracted into Docs and tests — ADR-0067, its index entry in the ADR README, and the app-definition-watching paragraph in the running-locally guide now record the Bun directory-import exception in the same terms the code uses. The worker tests assert both sides: a parse error leaves |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
commit: |
@alchemy.run/prisma moves to 2.0.0-beta.85 with it, and @distilled.cloud/prisma to 1.0.0-rc.18, the version it depends on. effect stays at 4.1.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…my-deploy-in-process Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ev-in-process Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…anch Keep our catalog pins (alchemy and @alchemy.run/prisma 2.0.0-beta.85, @distilled.cloud/prisma 1.0.0-rc.18, effect 4.1.0) and scratch-stack test imports. Take #402's footprint check (no @effect/vitest, vitest or vite; no @alchemy.run/prisma without the Prisma Cloud package), its process-listener check on the provider import, its ADR-0048 amendment and its effect-family pin rule in the upgrade skill. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…my-deploy-in-process Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ev-in-process Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…sma token optional alchemy-run/alchemy#3101 and alchemy-run/distilled#1076 let PrismaEnvironment and Distilled Credentials omit the service token, so an HttpClient can authenticate requests itself. Pin alchemy, @alchemy.run/prisma and @distilled.cloud/prisma to the pr:3101:ab55f95 previews, and move effect and its companions to 4.1.2, the floor of that Distilled build's effect peer. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…tate LowerOptions.credentials carries what the caller already authenticated. Core passes it to each extension's providers() and to the state descriptor's create(), so an extension can use the engine's client inside the converge instead of reading a token from process.env. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…plied client The Prisma provider bundle and the hosted state store now take the caller's Management API client (ctx.api under prisma deploy). Composer's own resources use it directly. Alchemy's providers, Distilled's operations and the state store get an Effect HttpClient that sends Management API requests through the client's per-method calls, with the body, query and headers unchanged and the response read as a stream; other hosts, such as presigned upload URLs, go to node's transport. PrismaEnvironment and Credentials carry only the base URL, so nothing but the client sets Authorization. Without a supplied client, one is built from PRISMA_SERVICE_TOKEN and used the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Deploy passes ctx.api and the active credential's workspace to lower() as values, so the providers authenticate through the engine's refreshing client. DEPLOY.SERVICE_TOKEN_REQUIRED, the command's serviceToken plumbing and the PRISMA_SERVICE_TOKEN and PRISMA_WORKSPACE_ID entries of the converge's environment overlay are removed. CONVERGE_CONTRACT goes to 2: an app on contract 1 would ignore the credentials and look for a token in the environment. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
ADR-0064's credentials section now records that every Management API request goes through the engine's client, and why: cli-engine keeps tokens away from commands. The deploy-cli domain doc, ADR-0044's code list, the guides and the core-concepts skill drop DEPLOY.SERVICE_TOKEN_REQUIRED, and the guides again say prisma auth login is enough for prisma deploy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…its peer npm ls compares dependency specs, so the pr:3101 URL and the tarball URL the provider names as its alchemy peer count as different packages even though one redirects to the other, and check:npm-effect-resolution failed on an invalid alchemy. Pinning the tarball URL makes the specs match. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ev-in-process Brings slice 4 (deploy authenticates through ctx.api) into the dev branch. Conflicts were in ADR-0044, ADR-0064 and the ADR index, where the dev amendments and the removal of DEPLOY.SERVICE_TOKEN_REQUIRED are combined, and in CLI tests that now pass the dev converge entries alongside credentials without a token. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
- The deploy HttpClient (renamed deployHttpClientLayer) removes every
request's own Authorization, so only the supplied client authenticates.
The state store no longer strips it itself.
- With a supplied client, Management API requests are recognised by the
origin from PRISMA_MANAGEMENT_API_URL, as the prisma CLI reads it. A
PRISMA_API_URL naming another host fails with
DEPLOY.MANAGEMENT_API_URL_CONFLICT before any container is resolved.
- Rebuilt JSON error bodies keep a JSON string's quotes.
- One choice between the supplied client and a token-built one
(suppliedOrFromEnv), used by the providers and the state store.
- providers({ credentials }) takes an input object, like preflight.
- ContainerCredentials is renamed CallerCredentials, in its own module.
- PrismaEnvironment no longer claims an environment service token when a
client is supplied.
- Tests: Authorization removal, env-built client keeps its token, JSON
string error body, byte/form/stream bodies with a 401 retry under bun
and node, env-only path sends Bearer, host conflict and match, and the
state store over a supplied client.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ev-in-process Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l deploy The deploy HTTP client provided its custom Fetch only while building FetchHttpClient.layer. The fetch client reads Fetch when it sends, from the context it was first built in, and a real deploy has already built FetchHttpClient.layer in the same layer memo map. The state store reused that instance, sent its requests with global fetch and the empty bearer token, and got HTTP 401 under a prisma login session. Provide Fetch on each Management API request instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ev-in-process Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the follow-ups from the #405 merge Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Each dev converge now runs in a new worker thread, which imports the config and the app as they are on disk, so an edit to an app definition file rebuilds and converges instead of pausing dev. The main thread holds the one-converge flag and changes to dev's cwd for the worker's life, forwards its events and output through the existing redacted paths, and turns an interruption, a crash or an early exit into an outcome. An edit that adds or removes a node fails the rebuild saying dev must be restarted. The definition-changed event is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…isma process Records why the app graph cannot be handed between threads, what crosses to the worker, how interruption and output are handled, and the limit that adding or removing a node still needs a restart. Amends the records, glossary, domain docs, guides and skill that described the dev stack file, the dev app configuration file and PRISMA_COMPOSER_NAMED_SECRETS. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
- Replace the worker's console methods and forward warnings under Bun, so nothing the app prints reaches the terminal unredacted. - Give the worker the cwd as the process resolves it, so a relative or symlinked cwd converges. - Compare the start graph's value reads with the edited app's in the worker, and pause with value-reads-changed when they differ. - Watch the app files a rebuild's import newly loads. - Send only each bundle's dir and entry; the in-thread seam clones the job. - Register the resolve hook before importing prisma.config.ts. - Keep a structured error's code, why and fix across the thread. - An aborted dev signal stops the session. - Rename the runner to runDevConvergeInWorker; correct the help text, the stop-timeout message and code text about dev's second process. - Pin localTargetProviders and devState in the converge contract test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The worker checks the platform variables the app reads and pauses on a change; newly imported files are watched; dev holds no state lease; the error registry lists the codes dev raises and retires DEV.STACK_WRITE_FAILED. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
- Replace every function on the worker's console, including Bun's console.write. - A failed import still returns the app files it recorded and the file its error names, so dev watches a file an edit imports before it exists. - Compare value-reads props in a plain form both sides share. - A first converge that sees other reads names them and no longer blames the module body. - DevConvergeResult is an outcome, an error envelope or value-reads-changed. - Correct two core messages for all three commands. - Take the real path of cwd once in executeDev; a directory mismatch inside the worker is reported as an internal fault. - Document DevInput.cwd and signal, and holdingConvergeProcess. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The decision record sample matches the code, the limits on redaction and on which edits still need a restart are stated, and the skill no longer says prisma dev starts Alchemy as a child. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…from an exports shim A character split across two chunks of the worker's stdout or stderr no longer prints as replacement characters. The worker build entry now points at src/exports like every other entry. The record-app-files test passes its paths as arguments instead of writing them into a script. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
- Build the console replacement from console.Console, so app code that imports node:console under Bun is redacted; leave the inspector-only console methods alone. - Watch every file the resolve hook would try for a missing import, and a file whose directory does not exist yet through its nearest existing ancestor. - Stop appFilesNamedBy on a looping cause chain and on a file URL with no local path. - Core exports propsAsData, which describes resource props as plain data, Values and Dates included; value reads compare through it. - Core names the error for a root input field an earlier Load did not read, and prisma dev reports it in its own words. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…-process Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> # Conflicts: # docs/design/10-domains/local-dev.md # docs/design/90-decisions/README.md # docs/guides/running-locally.md # packages/0-framework/3-tooling/cli/src/dev/__tests__/value-reads-change.test.ts # skills/prisma-composer-core-concepts/SKILL.md
- A failed import that names an existing directory now names the index file inside it, never the directory, so dev no longer watches a directory recursively. A missing path with a TypeScript extension is named alone. - comparableProps (was propsAsData) moves to @internal/core/deploy, off the @prisma/composer root entry. - Dev prints core's sentence, which names the field, after its own message for a root input field it did not read; on the first converge it gives the causes at start instead. - The worker's console.write behaves as Bun's: no separator, byte arrays and ArrayBuffers as text, the byte count returned. - Comments corrected or removed as the review asked. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…s a dot, and say when Bun keeps a failed directory lookup The rule for which files an import can resolve to lives in sourceCandidates alone again, so a missing ./app.config watches app.config.ts. Under Bun, a directory import that failed once keeps failing for the life of the process; the rebuild now says to restart prisma dev. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…reports the failure The worker returns the import error unchanged with a flag; the main thread adds the sentence, and only when the import names a directory that now has an index.ts. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
prisma devused to start the Alchemy CLI as a second process each time it applied your app. Now it does that work itself. This is what runs whileprisma devis applying an edit, before and after:What you see in the terminal is the same, and an edit to your app definition still applies without a restart:
The decision
Each time
prisma devapplies the app, it starts a new worker thread inside theprismaprocess, and the thread ends when the work ends. That happens once at start and once for every edit."Applying the app" (the code calls it a converge) is three steps: import
prisma.config.tsand the app definition, turn the app into the local resources it needs, and have Alchemy create or update those resources. The worker does all three. The main thread watches files, sends the worker plain data, and gets back progress events, output text and a result.prisma deployalready runs Alchemy in process since #405. This PR does the same forprisma dev.destroyis the one command left that starts the Alchemy CLI.Why a worker thread and not the main thread
prisma deployruns this work on the main thread, so the obvious design was to do the same inprisma dev. It does not work, for one reason: Node and Bun import a module once and then keep it.prisma devapplies the app many times. On the main thread, the second run would get the app definition as it was at start, and your edit would be ignored. The old design never met this problem, because every run was a new process.A new worker thread has its own module cache, in Node 24 and in Bun 1.3. So a worker started after your edit imports the files as they are on disk.
The worker also has to do the rest of the work, not only the import. An app definition is made of functions, and functions cannot be copied from one thread to another. So the thread that imports the app is the thread that applies it.
Nothing is lost by this.
prisma devneeds no Prisma credentials, so everything the worker needs can be sent to it as plain data.What changes for users
prisma devno longer writes.prisma-composer/dev/<environment>/alchemy.run.tsor an app configuration file, and no longer puts secrets in thePRISMA_COMPOSER_NAMED_SECRETSenvironment variable. Values go to the worker in memory.convergeat start andrebuild <n>after an edit, with its resources inside. This holds for the terminal and for--json.devmessages. One limit: code that writes straight to a file descriptor, such as a logger with its own destination, is not covered.prisma devends it and says so.Three kinds of edit still need a restart of
prisma dev. It tells you so, and leaves the running app as it was:mainhas the same limit today.mainwas meant to do this too, but its check ran in the first process, which held the app as it was at start, so it could never see such an edit. The check now runs in the worker and works.One more case needs a restart under Bun only. If you write an import of a directory (
./lib, meaninglib/index.ts) before the directory or itsindex.tsexists, Bun keeps that failed lookup for as long as the process runs.prisma devsays so when you create the file. An import of a file is not affected.Breaking changes
renderDevStackFileis removed from@prisma/composer-cli/testing.DEV.STACK_WRITE_FAILEDis retired. New codes:DEV.INTERRUPTED,DEV.CONVERGE_RUNNING,DEV.WORKER_THREAD,DEV.ENVIRONMENT_WRITE_FAILED.devoperation with acwdother than its own working directory will see its working directory change tocwdwhile each run lasts, and change back after. A worker thread cannot change directory, so the main thread does it.@prisma/composer/deployexports three new names for tooling:GRAPH_CHANGED_ERROR,ROOT_INPUT_UNREAD_ERRORandcomparableProps. Underprisma deploy, a root input field that was not read at start is now reported under the nameRootInputUnreadErrorin the engine failure's reasons; it wasCOMPOSE.GRAPH_INVALID.@prisma/composer/internal/converge) has two more exports,localTargetProvidersanddevState. Its contract number stays 2, because no release has shipped contract 2.Where to read
docs/design/90-decisions/ADR-0067-prisma-dev-converges-in-a-worker-thread.md. It extends ADR-0066, the record forprisma deploy.packages/0-framework/3-tooling/cli/src/operations/dev-converge-worker.ts.operations/dev-converge-in-worker.ts.operations/dev-converge.tsandoperations/dev-converge-messages.ts.converge-process.ts.Testing
consolemethod that prints, through a method imported fromnode:console, and throughprocess.stdout. The working directory is reached through a symlink. An edit adds a platform variable read. An edit imports a new file.@prisma/composerand@prisma/composer-clipackages contain the worker file beside the code that starts it.local-dev-store.integration.tspasses through the realprisma dev.storeexample (two Postgres databases, three services, a cron job and a Next.js front end run bynext dev), under Bun: start, a schedule edit applied on save, Ctrl-C,--detach,dev stop.root-inputexample, under Bun and Node: start, an edit applied on save, a syntax error and its fix, an added node, an added platform variable read, a newly imported file (also one that did not exist yet), a newly imported file in a directory that did not exist yet, a new root input field, Ctrl-C while idle and during a rebuild.alchemyprocess ran, and no stack file or app configuration file was written.Not in this PR
destroystill generates a stack file and starts the Alchemy CLI.Alternatives considered
prisma devafter every edit to the app definition. Such an edit applied without a restart before this change, so this would be a step back.Agent: dante-73 (opened by maat-73)
🤖 Generated with Claude Code