Repository navigation
fix(functions): serve the other functions when one fails to load, and answer its route with a 502 - #329
Merged
Conversation
… answer its route with a 502 Each deployed AWS function is its own Lambda, so a file that throws while loading (or fails to bundle) fails only its own route, with a 502, and every other function keeps working. Serve stopped with FunctionLoadError instead, so one half-finished function made every other function unreachable locally. Serve now logs the same "Could not load functions/<file>.js: <cause>" message, with the file, line and column, when it starts and on each request to that route, and the route answers a bare 502. Every other function serves as before. A package that is not installed still stops serve with MissingPackageError, since that is the local install, not the function's code. The tests that expected serve to refuse now pin the same messages and locations from the log, and the 502. AGENTS.md describes the change, and the .talismanrc checksums of the two touched files are refreshed.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
chhavi-mandowara-cstk
requested review from
Harshi-Shah-CS,
SakshiKoli-CS,
dhruv-parekh-cs and
siddharth-kulkarni-cs
December 4, 2026 13:11
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
dhruv-parekh-cs
approved these changes
Dec 4, 2026
tejas-contentstack
pushed a commit
that referenced
this pull request
Dec 4, 2026
Brings in the functions fixes from #327, #328 and #329. The only conflict was .talismanrc, the AGENTS.md checksum line: both sides had changed it, so it is recomputed with Talisman for the merged AGENTS.md. All of our other .talismanrc entries are kept as they were. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <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.
What was wrong
A function file that throws while it loads (for example
if (!process.env.X) throw …at the top), or that fails to bundle, madelaunch:functions:serveexit 1 withCould not load functions/<file>.js: …. Every other function was then unreachable locally.Deployed, it depends on the cloud:
package: individually: true, one handler per file insetup_cloud_functions.go). Only the bad file's Lambda fails to start.v2-devloadCloudFunctionResourcesthrowsFunctionLoadErrorfor the first file that fails.This is CL-8970 gap 9.
The change (
src/functions/cloud-functions.ts)FunctionLoadErrormessage is logged instead: the sameCould not load functions/<file>.js: <cause> (<file>:<line>:<column>)as before. It is logged when serve starts, and again on each request to that route, so a 502 always comes with its reason.items/[id].js) keeps its shape.MissingPackageError("… Run npm install in the project"). That is the local install, not the function's code; on AWS the deploy installs packages.AGENTS.mddescribes the new behaviour and what Azure/GCP (V1) do..talismanrc: refreshed checksums forcloud-functions.test.tsandAGENTS.md(test code and prose, no credentials).Tests
src/functions/cloud-functions.test.ts:serves the other functions when one throws while loading, and answers its route with a bare 502:/okgives 200ok,/brokena bare 502, and the reason is logged.logs why a route answers 502 when serve starts and again on each request to it: logged once at start, then once per request.answers a 502 on a dynamic route whose function fails to load, keeping its path parameter.file:line:col;file:line:col;api/boom.js;MissingPackageErrortests are unchanged and still pass.Proof:
v2-dev, the new tests fail: serve rejects withFunctionLoadError.Full suite in the pre-push hook: 189 suites, 3847 tests passed. Every hook ran (Snyk included), with no
--no-verify.E2E (http-sanity cloud-functions checks, AWS expectations)
Gap 9 can't go into the shared 30-check site: on Azure/GCP one bad file would make every check answer 500. So e2e PR contentstack/contentfly-e2e-tests#503 adds a separate small site (
ok.js, and abroken.jsthat throws while loading). It is deployed to its own environment, behind the sameLAUNCH_E2E_CLOUD_FUNCTION_PARITYswitch.Against
launch:functions:serve:v2-dev(5eb03c8)Could not load functions/broken.js: …)/ok200ok,/broken502require/__dirname)Not changed
Detected Serverless Functions) still lists the failed route; the logged message above it says why it answers 502.Jira: https://contentstack.atlassian.net/browse/CL-8970
Generated by Claude Code