world-postgres: support an enqueue-only process (`WORKFLOW_POSTGRES_WORKER_CONCURRENCY=0` / `queueConcurrency: 0`)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, postgresql, typescript
调研方向
Start by reading the Postgres World's createWorld(), startRunnerWhenExecutorIsReady(), setupListeners(), and queue() paths in dist/index.js and dist/queue.js; compare them with the source and current tests. Check how zero is parsed and passed to Graphile's run(), and how the loopback deferred start behaves. Done means a zero-concurrency World can enqueue after migrations without starting a runner, while a nonzero concurrency still runs jobs; the issue offers a real Postgres test scenario.
由索引模型根据 Issue 内容生成。
描述
What we want
We run the Postgres World in two kinds of processes of the same Next app:
- web replicas that serve HTTP and start runs (
start()→world.queue()), but should never execute a flow or step; - worker replicas that run Graphile's runner and execute everything over loopback.
Separating them keeps long steps out of the web replicas (no job slots held there, no drain on shutdown) and lets the two scale independently. For this the web replicas need a World whose queue() adds the Graphile job but whose start() never starts a runner.
What happens today (@workflow/[email protected], and the same on main)
There is no enqueue-only mode, and a concurrency of 0 cannot express one:
createWorld()'s default config computesqueueConcurrency: parseInt(process.env.WORKFLOW_POSTGRES_WORKER_CONCURRENCY || '10', 10) || 10(|| '50' … || 50onmain), soWORKFLOW_POSTGRES_WORKER_CONCURRENCY=0becomes 10 (50).setupListeners()passesconcurrency: config.queueConcurrency || 10(|| 50onmain) to Graphile'srun(), so an explicitqueueConcurrency: 0also becomes 10 (50).queue()awaitsstart(), andstart()always callsstartRunnerWhenExecutorIsReady()aftermakeWorkerUtils()/migrate(), starting the runner at once or deferred behind the loopback probe. So any process that enqueues also executes.
Proposal
Treat a concurrency of 0 as "enqueue only":
- keep a parsed
0in the default config (fall back to the default only when the variable is missing or not a number); - in
startRunnerWhenExecutorIsReady(), return early whenconfig.queueConcurrency === 0(this covers both call sites instart()and the deferred loopback path), whilestart()still makes the worker utils and runs the Graphile and pg-boss migrations so thatqueue()works; - use
config.queueConcurrency ?? <default>insetupListeners().
close() already handles a missing runner, and reenqueueActiveRuns in world.start() stays harmless on such a process since it enqueues by job key. An explicit option (e.g. mode: 'enqueue-only' or runner: false) would be equally fine for us if you prefer it over overloading 0; a 4.x release with it would let us drop our patch.
What we do meanwhile
We pin a three-place patch of dist/index.js and dist/queue.js of 4.3.7 (via Bun's patchedDependencies) doing exactly the above, and verify it against real Postgres: a World with queueConcurrency: 0 (explicitly and through WORKFLOW_POSTGRES_WORKER_CONCURRENCY=0) enqueues a workflow message that stays in graphile_worker.jobs while a stub executor receives no request; a World with 10 delivers it and the job is gone. Happy to open a PR with the change and such a test if that helps.
Related, noticed while testing (separate issue if you like)
Under Bun, world.close() throws TypeError: httpAgent?.close is not a function from the embedded local World (@workflow/[email protected], dist/queue.js close()), apparently because the undici Agent that Bun resolves there has no close(); the Postgres World's close() then never reaches pool.end(). Setting WORKFLOW_NODE_HTTP=1 avoids it.
- 主要语言
- TypeScript
- 星标
- 2.5k
- 派生
- 401
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 201
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
vercel/workflow 的其他 Issue
-
getPortLazy re-runs OS port discovery on every call when it finds no port可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
node-module-esbuild-plugin: getImportedIdentifier only checks the first named import when locating a violation可能已有人在做 @div-cowboy 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
vercel/workflow#5057 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
code-transform.mdx §ID Generation omits the package-shipped `name@version` ID form可能已有人在做 @Mohith26 于 113 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
相似的 Issue
-
type: bug
难度 2/5 1-3 小时 新手友好度 78/100
nrwl/nx#37955 · 1 个 reaction ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
db-ux-design-system/core-web#8856 ·
维护者通常 1 天内回复
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footer可能已有人在做 @wittdennis 今天认领。 未关闭priority: p3 type: bug
难度 2/5 1-3 小时 新手友好度 74/100
googleapis/release-please#2971 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 87/100
维护者通常 1 天内回复
-
🛠️ dette technique
难度 2/5 1-3 小时 新手友好度 61/100
betagouv/mon-entreprise#4752 · 1 条评论 ·
维护者通常 5 天内回复