Skip to content

refactor: extract wait_until context from cache - #373

Open
fantix wants to merge 2 commits into
mainfrom
fantix/invocation-background-tasks
Open

fantix wants to merge 2 commits into
mainfrom
fantix/invocation-background-tasks

Conversation

@fantix

@fantix fantix commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Upcoming workflow ReadableStream would start background tasks to pump data from user generators into a workflow stream. Such task should continue to run to completion even after the step handler returns. This is what vercel.functions.wait_until(awaitable) offers, and the Workflow JS SDK is using similar mechanism.

The problem is, neither vercel.functions (the vercel package) nor the underlying context storage of wait_until (currently stored in vercel.cache.context, in vercel-cache package) can be imported from vercel-workflow - workflow doesn't have to depend on cache.

This PR moves that context storage to vercel.functions.context in vercel-internal-core. The rest of vercel.functions stays in the vercel meta package, with pkgutil.extend_path() allowing the workspace to combine it with the context subpackage from internal core.

vercel.functions.context is not considered public API - it's only used by the runtime and other vercel-* packages internally. Therefore, vercel.functions didn't re-export what's in the context module.

This also allows the runtime to avoid using the confusing vercel.cache.context.set_context(), but rather use the more accurate vercel.functions.context.set_wait_until(). See also the paired runtime change: https://github.com/vercel/vercel-internal/pull/786

See also: #2, #59, #149, #218

Expose wait-until state through vercel.functions.context so runtimes
and SDK packages can share invocation ownership without depending on
cache. Preserve meta package ownership of the existing Functions API.
Include the public API and error namespace portions in the package mypy
roots so every module shipped by internal core is checked.
@fantix fantix changed the title Extract invocation background task context Add shared Functions invocation context Sep 3, 2026
@fantix fantix changed the title Add shared Functions invocation context refactor: extract wait_until context from cache Sep 3, 2026
@fantix
fantix marked this pull request as ready for review September 3, 2026 20:58
@fantix
fantix requested review from a team and ricardo-agz September 3, 2026 20:58
@fantix

fantix commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

This is decided in a meeting to get moved into vercel-context package.

This branch was successfully deployed

1 active deployment
ci — 11e97d23 Deployed Sep 3, 2026 by fantix via Test (Windows, py3.13) #1403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant