Fix: getGlobalSettings accumulates orphaned listeners under concurrent or interleaved calls#139
Open
popcornhax wants to merge 2 commits intoelgatosf:mainfrom
Open
Fix: getGlobalSettings accumulates orphaned listeners under concurrent or interleaved calls#139popcornhax wants to merge 2 commits intoelgatosf:mainfrom
popcornhax wants to merge 2 commits intoelgatosf:mainfrom
Conversation
…interleaved calls getGlobalSettings() currently uses connection.once() with no id filtering and no timeout. If a didReceiveGlobalSettings event arrives from an unrelated trigger (e.g., the property inspector) while a getGlobalSettings() promise is pending, the wrong event resolves the promise and the listener registered for the actual response is permanently orphaned. Under repeated calls this silently accumulates listeners. This PR aligns getGlobalSettings() with the pattern already used by Action#fetch(): match by request id, use connection.disposableOn() for safe cleanup, and add a timeout to prevent indefinite awaiting. The DidReceiveGlobalSettings type already carries an optional id field for this purpose.
Fixed import, timeout and formatting.
GeekyEggo
requested changes
Mar 5, 2026
Member
GeekyEggo
left a comment
There was a problem hiding this comment.
Thank you for the PR; overall the changes look good, just one minor change request.
| }, REQUEST_TIMEOUT); | ||
|
|
||
| const listener = connection.disposableOn("didReceiveGlobalSettings", (ev: DidReceiveGlobalSettings<T>): void => { | ||
| if (ev.id === id) { |
Member
There was a problem hiding this comment.
This id check can be removed; with global settings being shared, it's safe to assume that any didReceiveGlobalSettings event can fulfil any-and-all pending promises.
For request completeness, the id should still be sent with the request, but needn't be checked when receiving the global settings, e.g. the following is fine:
connection.send({
event: "getGlobalSettings",
context: connection.registrationParameters.pluginUUID,
id: randomUUID(),
});
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.
getGlobalSettings() currently uses connection.once() with no id filtering and no timeout. If a didReceiveGlobalSettings event arrives from an unrelated trigger (e.g., the property inspector) while a getGlobalSettings() promise is pending, the wrong event resolves the promise and the listener registered for the actual response is permanently orphaned. Under repeated calls this silently accumulates listeners.
This PR aligns getGlobalSettings() with the pattern already used by Action#fetch(): match by request id, use connection.disposableOn() for safe cleanup, and add a timeout to prevent indefinite awaiting. The DidReceiveGlobalSettings type already carries an optional id field for this purpose.