Skip to content

fix: avoid potentially infinite hangs on async messages #669

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

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

ACTCD
Copy link
Collaborator

@ACTCD ACTCD commented Jul 9, 2024

When using GM APIs, if the background script returns an undefined value, the reply may never be delivered, and awaiting the promise will cause the script to hang indefinitely.

The issue existed in the latest release version, but since undefined values were not returned in most cases, it was unlikely that the error would be encountered except in some edge cases.

However, with the revise of GM APIs in #570 (currently still in beta versions), which brought in more possibilities of returning undefined values, the issue was finally exposed.

Fix this by avoiding returning any undefined values, use predefined structured message objects.

@ACTCD ACTCD requested a review from quoid July 9, 2024 06:21
Copy link
Owner

@quoid quoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes make sense to me 👍.

ACTCD added a commit that referenced this pull request Jul 11, 2024
@ACTCD ACTCD mentioned this pull request Jul 11, 2024
Base automatically changed from fastlane to main July 12, 2024 07:10
@ACTCD ACTCD merged commit a88d4b6 into main Jul 12, 2024
1 check passed
@ACTCD ACTCD deleted the fix/api-infinite-hang branch July 12, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants