Repository navigation
fix(stack): reuse the Deno cache when booting Edge Function workers - #7347
Merged
Coly010 merged 2 commits intoOct 27, 2026
Conversation
The stack bootstrap created user workers with `noModuleCache: true`, which
puts each worker's Deno cache into reload mode. Every worker then downloads
its npm packages again and, when a package is already cached, re-extracts it
in place in the shared cache. Workers booting at the same time collide on the
same files and fail with 503 BOOT_ERROR ("File exists (os error 17)" or
"No such file or directory").
Create workers with `noModuleCache: false`, as classic `functions serve`
does, so cached packages are reused. Add an integration test that boots
workers concurrently against a local npm registry and checks the cached
package is not downloaded again.
Closes #7321
Contributor
There was a problem hiding this comment.
🤖 AI Review
Both independent reviews reported zero findings. Inspection of the PR code found no additional issues: the cache setting, generated bundle, and regression tests are consistent. No fundamental conflict with the pending next-branch work was identified. Tests were not run during adjudication.
Findings
No issues found.
Stats
Claude findings: 0 · Codex findings: 0 · Confirmed: 0 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
jgoux
approved these changes
Oct 27, 2026
Coly010
deleted the
columferry/cli-2850-stack-mode-edge-functions-that-boot-at-the-same-moment-fail
branch
October 27, 2026 14:34
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.
Summary
In stack mode, Edge Functions that boot at the same time can fail with
503 BOOT_ERROR. The logs showFailed caching npm package … File exists (os error 17), orNo such file or directorywhen reading a cached package file. This setsnoModuleCache: falsewhen the stack bootstrap creates user workers, which is what classicfunctions servealready does.What's going on
noModuleCache: trueputs the worker's Deno cache into reload mode. Each worker builds its own npm cache, so nothing is shared between workers, and each one downloads every npm package it imports again. When that package is already in the sharedDENO_DIR, Deno extracts it again in place, over the live copy, deleting and recreating each file. Two workers doing that at the same time collide, and a worker that reads a file in the middle of it finds it missing.flowchart TD boot["Worker boots and imports npm:pkg"] --> flag{"noModuleCache"} flag -- "false" --> cached{"pkg in the cache?"} cached -- "yes" --> reuse["Reuse it"] cached -- "no" --> temp["Extract to a temp dir,<br/>then rename into place"] flag -- "true" --> cached2{"pkg in the cache?"} cached2 -- "no" --> temp cached2 -- "yes" --> inplace["Extract again in place,<br/>over the live copy"] inplace --> fail["Concurrent boots collide<br/>503 BOOT_ERROR"]This explains the odd parts of the report:
stopandstart, so it fails much more often than Docker, whose new container starts with an empty cache.forceCreate: trueboots a new worker for every request, so every request goes down this path. I've left it as it is, because it's what makes edits show up without a restart.Against Edge Runtime directly, with only this flag changed, 40 of 64 concurrent boots failed with it on and none of 112 failed with it off.
What changes
npm:x@lateststay on the cached version until the cache resets (a new container on Docker,stack destroyon native). That matches classicfunctions serveanddeno run.Earlier bootstraps and classic
functions serveusefalse. Iftruewas there for something I've missed, I'm happy to talk it through.Linked issue
Closes #7321 (CLI-2850)