-
Notifications
You must be signed in to change notification settings - Fork 100
fix(core): make handleUnsubscribeEvent and handleUnobserveProperty async #1480
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
base: master
Are you sure you want to change the base?
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -572,11 +572,11 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { | |||||||||||||
| * | ||||||||||||||
| * @experimental | ||||||||||||||
| */ | ||||||||||||||
| public handleUnsubscribeEvent( | ||||||||||||||
| public async handleUnsubscribeEvent( | ||||||||||||||
| name: string, | ||||||||||||||
| listener: ContentListener, | ||||||||||||||
| options: WoT.InteractionOptions & { formIndex: number } | ||||||||||||||
| ): void { | ||||||||||||||
| ): Promise<void> { | ||||||||||||||
|
Comment on lines
+575
to
+579
|
||||||||||||||
| if (this.events[name] != null) { | ||||||||||||||
| Helpers.validateInteractionOptions(this, this.events[name], options); | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -595,7 +595,7 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { | |||||||||||||
| } | ||||||||||||||
| const unsubscribe = this.#eventHandlers.get(name)?.unsubscribe; | ||||||||||||||
| if (unsubscribe) { | ||||||||||||||
| unsubscribe(options); | ||||||||||||||
| await unsubscribe(options); | ||||||||||||||
| } | ||||||||||||||
| debug(`ExposedThing '${this.title}' unsubscribes from event '${name}'`); | ||||||||||||||
| } else { | ||||||||||||||
|
|
@@ -639,11 +639,11 @@ export default class ExposedThing extends TD.Thing implements WoT.ExposedThing { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| /** | |
| * | |
| * @experimental | |
| */ |
Copilot
AI
Feb 12, 2026
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.
This is a breaking API change. The method signature is being changed from returning void to returning Promise<void>, but none of the callers in the binding implementations are being updated to await this promise. This will result in floating promises and broken error handling.
All callers need to be updated to await this method:
- packages/binding-coap/src/coap-server.ts:701, 704
- packages/binding-http/src/routes/property-observe.ts:91, 107, 109
- packages/binding-websockets/src/ws-server.ts:236
Many of these calls are in event handlers (res.on("finish"), setTimeout) where the returned promise may not be properly handled. Consider whether this change should be made atomically with updates to all callers, or if error handling needs to be added to gracefully handle floating promises in these contexts.
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.
Shouldn't we handle error cases?