Repository navigation
fix(lambda): build the layer again after a failed build - #237
Open
TheHolyWaffle wants to merge 2 commits into
Open
TheHolyWaffle wants to merge 2 commits into
TheHolyWaffle wants to merge 2 commits into
Conversation
馃 Changeset detectedLatest commit: b5f9efd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A ManagedRuntime keeps a failed layer build, so a transient failure during a cold start failed every later invocation of the container. The handlers now dispose a runtime whose build failed, which also evicts the failure from a shared memoMap, and the next invocation builds the layer again. makeWebHandler builds the router itself, so a failed router build fails the WebHandler layer instead of every request inside HttpRouter.toWebHandler. Closes floydspace#235
TheHolyWaffle
force-pushed
the
fix/lambda-rebuild-after-failed-build
branch
from
October 3, 2026 08:43
9d6def4 to
1bd5443
Compare
HttpRouter.toHttpEffect builds in a fork of the memo map, so layers built for a fromHttpApi handler weren't shared with other handlers using the same memoMap. makeWebHandler now builds the router directly in options.memoMap.
This branch has not been deployed
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.
Closes #235.
A
ManagedRuntimekeeps a failed layer build, so a transient failure during a Lambda cold start (a database still scaling, a throttled Secrets Manager or SSM call) failed every later invocation of the container until AWS recycled it.Changes
make,streamandstreamFromHttpApirun on a new internal runner (internal/runtime.ts). When the runtime's build fails, the runner disposes that runtime and replaces it with a fresh one, so the next invocation builds the layer again. Disposing also closes the failed build's scope, which evicts it from a sharedmemoMap.makeWebHandlerbuilds the router withHttpRouter.toHttpEffectand serves it withHttpEffect.toWebHandlerWith, instead ofHttpRouter.toWebHandler.toWebHandlerstarts its own build and rejects every request when that build fails, while theWebHandlerlayer around it still succeeded, so the runner never saw the failure. A failed router build now fails theWebHandlerlayer. The defaultHttpMiddleware.loggerand themiddlewareoption compose astoWebHandlercomposes them.LambdaRuntime.fromLayerkeeps its signature and behaviour; its signal handling moved into the internal module so the runner can share it.Behaviour change
makeWebHandler's error channel now carries the router layer's error, since the build happens there.Tests
Two new tests, both failing on
mainand passing here:LambdaHandler.makewith a layer that fails its first build: the first invocation rejects, later ones succeed, and the layer is built twice.LambdaHandler.fromHttpApiwith an API layer that fails its first build: the first invocation rejects, the second answers 200.I also ran the repro from #235 against the packed
dist: