-
Notifications
You must be signed in to change notification settings - Fork 342
fix(extensions): preserve live handler context accessors #3818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,16 @@ export function testSetExtensionHandlerTimeoutMs(timeoutMs: number): void { | |
| const EXTENSION_HANDLER_TIMEOUT = Symbol("extensionHandlerTimeout"); | ||
|
|
||
| const MAX_PENDING_CREDENTIAL_DISABLED = 32; | ||
| function createHandlerContext(ctx: ExtensionContext, signal: AbortSignal): ExtensionContext { | ||
| const descriptors = Object.getOwnPropertyDescriptors(ctx); | ||
| descriptors.signal = { | ||
| configurable: true, | ||
| enumerable: true, | ||
| writable: true, | ||
| value: signal, | ||
|
Comment on lines
+84
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an extension assigns a replacement to Useful? React with 👍 / 👎. |
||
| }; | ||
| return Object.defineProperties({}, descriptors) as ExtensionContext; | ||
| } | ||
|
|
||
| /** | ||
| * Events handled by the generic emit() method. | ||
|
|
@@ -690,7 +700,7 @@ export class ExtensionRunner { | |
| ): Promise<TResult | undefined> { | ||
| let timeout: NodeJS.Timeout | undefined; | ||
| const abortController = new AbortController(); | ||
| const handlerContext: ExtensionContext = { ...ctx, signal: abortController.signal }; | ||
| const handlerContext = createHandlerContext(ctx, abortController.signal); | ||
| try { | ||
| const timeoutPromise = new Promise<typeof EXTENSION_HANDLER_TIMEOUT>(resolve => { | ||
| timeout = setTimeout(() => resolve(EXTENSION_HANDLER_TIMEOUT), timeoutMs); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an extension assigns a handler-local replacement to
ctx.model, which the non-readonlyExtensionContext.modeldeclaration permits and the previous spread produced as a writable data property, copying this getter descriptor leaves it getter-only. In strict-mode extension modules,ctx.model = replacementnow throws aTypeError, causing the runner to report the handler as failed and skip its remaining work; preserve the live getter while still allowing a local assignment override.Useful? React with 👍 / 👎.