Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8965246
fix(functions): end a response the handler leaves open, as deployed f…
claude Nov 27, 2026
18aada4
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
e99ef53
fix(functions): guard every late header call and let a file send finish
claude Nov 27, 2026
b872797
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
a55dfae
fix(functions): settle file sends and guard every ended response
claude Nov 27, 2026
6662391
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
088dcc2
fix(functions): guard every finished response and close piped sources
claude Nov 27, 2026
5b11fbe
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
fa7735d
fix(functions): guard late changes from the start and survive an inva…
claude Nov 27, 2026
9b95f1f
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
d516665
fix(functions): release piped streams on close and never crash answer…
claude Nov 27, 2026
9d63bfa
chore: refresh .talismanrc checksum for AGENTS.md
claude Nov 27, 2026
27a2f35
fix(functions): release only what serve owns, and never crash on a fo…
claude Nov 27, 2026
2c08689
chore: refresh .talismanrc checksum for cloud-functions.test.ts
claude Nov 27, 2026
f6f8ddd
fix(functions): drain a released stream instead of leaving it paused
claude Nov 27, 2026
ed948ba
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
4b128ee
fix(functions): resume a released stream only for a reader it still has
claude Nov 27, 2026
c30e51b
chore: refresh .talismanrc checksums for cloud-functions.test.ts and …
claude Nov 27, 2026
c225c9d
fix(functions): drain a released request body, and release a late pip…
claude Nov 27, 2026
294fd07
fix(functions): drain only the exchange's request, and unpipe a late …
claude Nov 27, 2026
738037a
chore: refresh .talismanrc checksum for AGENTS.md
claude Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fileignoreconfig:
- "a project name passed on argv to the project resolver"
- "expect\\(Object.keys\\(DEPENDENCIES\\)\\).toEqual\\(\\['project', 'env'\\]\\)"
- filename: AGENTS.md
checksum: d9ece4c45007c65054469efcd50de93573c756ad9664a6a2d7658db021a5078c
checksum: f21023b4c3d85ca532cf5956577f0ebaf340bf99d353b0ee1ce1f0a43a9acf92
allowed_patterns:
- "Do not add an exemption to a guard to make a new file pass"
- "passes its own error wording to `client.request\\(req, MESSAGES\\)`"
Expand Down Expand Up @@ -287,7 +287,7 @@ fileignoreconfig:
- filename: test/integration/projects-list-command.test.ts
checksum: 038f5cd182e1fd0105e6e10dde7f5068a0c15883222450f72ea3904890a56c0c
- filename: src/functions/cloud-functions.test.ts
checksum: ca4e03b4ae6d4e39fe5ad654f781b002deb37f2f30ebf58c27feeb162696c562
checksum: 126ebc9a778b18a0601e5c11cbf1b6441a5989b558bb276ae640cbc7b33fe712
- filename: src/functions/function.errors.ts
checksum: a24194bef73c8db8c28b8ac104955f2f22abdc8c8d0608fa36a39032055bda57
- filename: src/transport/proxy.test.ts
Expand Down
31 changes: 31 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,33 @@ The approved differences from V1 are these, and only these:
`res.redirect(url)` with a 302 and a body, treat `res.send(404)` as a 404 status and an
invalid one such as `res.send(42)` as a 500, and honour the two-argument forms of `res.send`
and `res.json`.
A handler that returns (or whose promise settles) without ending its response is ended for it
at once with the status and headers it set, as AWS's `finalizeResponse` does (CL-8970); a
response whose headers were already sent, or that `res.sendFile`/`res.download` is still
sending, is left for the handler to end; a file send that throws, or whose callback leaves the
response open, is ended the same way once it settles. Once a response has ended, for whatever
reason, any later change to it (`end` with a body, `write`, header calls, a file send, and so
`send`, `json` and `redirect`) is ignored with one `warn:` line naming the requested URL instead
of crashing serve; a callback passed to it gets `ERR_STREAM_WRITE_AFTER_END` (`write`, or `end`
with a body) or `ERR_STREAM_ALREADY_FINISHED`, as Node does. An `end()` with no body is Node's own
no-op and is not warned about (`res.json(data).end()`). Once a response closes, or when a stream
is piped into one that has already ended or whose client has gone, each stream piped into it is
unpiped (if it can be). On the next turn the exchange's own request body is drained, as Node
would dump it, so the connection can serve its next request; a file stream (`fs.ReadStream`) that
nothing else reads is destroyed, so it does not keep its file descriptor open; and a stream that
still has a `'data'` reader is resumed so that reader gets the rest. Any other stream is left
paused, as Node leaves it after an unpipe (a stream piped into an already-ended response is
paused again after `pipe()` resumes it), for the function to resume or close: a file stream or
the request behind a transform (for example gzip), a child's stdout or an upstream body then
stays open, or stalls that keep-alive connection, until the function closes it. If ending the
response for the handler fails (an invalid status, a content-length mismatch), or a handler throws
before its headers were sent, serve logs the error and answers a `cache-control: no-store` 500
without the headers the handler had set, dropping the connection if even that cannot be sent.
So a callback that answers after the handler returned gets an empty response, exactly as on AWS.
Because serve wraps `res.sendFile`/`download`/`sendfile` to track them, Express's deprecation
warning for the lowercase `res.sendfile` names serve's file, not the function's. Azure and GCP (V1) still
deliver such a late answer as written, and answer a handler that never ends its response with
504 CF005 after the timeout.
- **A function that reaches a file outside `functions/` is warned about, not refused**, naming
the function file that crosses the boundary.
- **Errors name the user's file.** A function that fails to bundle or load stops serve with
Expand Down Expand Up @@ -1084,6 +1111,10 @@ and the agent would then wait forever for a port that never opens. Never replace
2.x build without changing `SERVER_COMMAND` to `launch:functions:serve` in the same change. The same
applies to any customer `package.json` script that runs `launch:functions`: it is a release-note line
for 2.0, and the umbrella `@contentstack/cli` must keep pinning `cli-launch@^1` until 2.0 is GA.
Moving Azure and GCP to 2.x also changes how their functions answer: 2.x serve ends a response the
handler leaves open as AWS does (CL-8970), so a handler that answers from a callback after it
returned, which those clouds deliver today, gets an empty response instead. Say so in the agent's
release notes.

**`this.dataDir`.** `LaunchCommand` already computed the data directory to find `.cs-launch.json`;
it now exposes it, because `projects:create` has to zip that same directory and `--data-dir` is a
Expand Down
Loading
Loading