fix(queue): widen upsertJobScheduler id parameter to free string - #4107
Open
mohanrajvenkatesan23-04 wants to merge 1 commit into
Open
Conversation
manast
requested review from
Copilot and
roggervalf
and removed request for
Copilot
July 15, 2026 18:10
The first parameter of Queue.upsertJobScheduler was typed as the queue's NameType generic, which incorrectly coupled the scheduler's unique identifier to the union of job names. Distributed setups typically use a per-instance UUID for the scheduler id while the job names remain a fixed literal union, so typed queues rejected any non-literal scheduler id at compile time. The underlying JobScheduler.upsertJobScheduler already types the id as `string`; this aligns the public Queue API with that, and casts the no-name fallback to NameType so the existing runtime behaviour (falling back to the scheduler id when no template name is given) is preserved. Fixes taskforcesh#3937
roggervalf
force-pushed
the
fix/issue-3937-scheduler-id-type
branch
from
July 16, 2026 03:29
545c89b to
696af47
Compare
Contributor
|
@copilot resolve the merge conflicts in this pull request |
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.
Port Impact Checklist
Why
Fixes #3937.
Queue.upsertJobScheduler's first parameterjobSchedulerIdwas typed as the queue'sNameTypegeneric. This created a hard coupling between the scheduler's unique identifier and the union of job names the queue produces. In real distributed setups the scheduler id is typically a per-instance UUID (inst_12345, a database row id, etc.) that has nothing to do with the job-name literal union, so any typed queue rejected the call at compile time:The underlying
JobScheduler.upsertJobScheduleralready types the id correctly asstring(with the job name as a separateN extends string = stringgeneric) — the bug was a leak in the publicQueuewrapper.How
src/classes/queue.ts: change the parameter type fromjobSchedulerId: NameTypetojobSchedulerId: string. This matches the underlyingJobScheduler.upsertJobSchedulersignature.jobTemplate?.name ?? jobSchedulerIdis nowjobTemplate?.name ?? (jobSchedulerId as NameType). The cast is intentional and preserves the existing runtime behaviour: when the caller does not supply a template name, the resulting job's name is still the scheduler id. Users who want strict type safety on the produced job's name should passjobTemplate.nameexplicitly (which the issue's example already does).JobScheduleritself — the underlying API was already correct.Additional Notes (Optional)
tests/job_scheduler.test.ts(when the queue has a constrained NameType) that builds aQueue<unknown, unknown, 'generate-report' | 'send-email'>and callsupsertJobSchedulerwith a free-string id. Before the fix this fails to compile; after, it compiles and the runtime asserts the resulting job's name is'generate-report'.