Repository navigation
Conversation
`init()` guards on `this.config[command.name]` when it schedules the deferred
task, but the task re-reads the same map when it fires one tick later. When a
later write removes the override, the pending callback calls `accept` with
`undefined` and destructuring throws:
Uncaught TypeError: Cannot destructure property 'create' of 'override' as it is undefined.
at CommandManager.accept (plugins/commands/src/index.ts:266:13)
at <anonymous> (plugins/commands/src/index.ts:150:12)
`ctx.setTimeout` invokes the callback inside a raw `setTimeout`, so the throw
escapes as an unhandled exception. Read the override into a local and skip the
call when it is gone; the callback still observes the freshest value.
This branch has not been deployed
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.
Problem
init()guards onthis.config[command.name]when it schedules the task, butthe task re-reads the same mutable map when it fires, one tick later:
write()deletes the entry and then emitscommand-updated, which callsinit(). When a previous write has a task pending and the next write removes theoverride, the pending callback fires against an empty map and
acceptdestructuresundefined:ctx.setTimeoutcalls the callback directly inside a rawsetTimeout, so thisescapes as an unhandled exception rather than a logged one.
accept's thirdparameter and its own contract ("create snapshot for restoration; override config
and options") both assume an override exists.
Changes
The callback still observes the freshest override — it only declines to run when
there is none, which is what the guard three lines above already states.
Regression coverage
plugins/commands/tests/index.spec.tsadds one case: add an alias, remove it,then let the pending task fire.
On
mainit fails with theTypeErrorabove (the uncaught exception alsoaborts the run — 8 later cases never execute); with the change the file is
14 passing.
corepack yarn yakumo tsc commandsexits 0.Scope
plugins/commands/src/index.tsonly.accept()and its other two callers areuntouched, and no other package is involved.