Skip to content

Conversation

@AllanChain
Copy link
Contributor

@AllanChain AllanChain commented Aug 28, 2023

Fixes #10107

If there is an error in the child iframe beforeunload, the promise will never resolve, making us wait infinitely. Therefore, the try{}catch{} block is not working as expected:

try {
await this._caller?.callUserModel(
AWAIT_LSPMSGFn(LSPMSG_BEFORE_UNLOAD),
eventBeforeUnload
)
this.emit('beforeunload', eventBeforeUnload)
} catch (e) {
this.logger.error('[beforeunload Error]', e)
}

This PR rejects child promise on error so that the try{}catch{} block is catching the error.

To test it, follow #10107 but change @logseq/libs to the development one.

One question, should I update LSPlugin.core.js in this PR?

@github-actions github-actions bot added the fix label Aug 28, 2023
@andelf andelf requested a review from xyhp915 August 29, 2023 06:33
@xyhp915
Copy link
Collaborator

xyhp915 commented Aug 29, 2023

One question, should I update LSPlugin.core.js in this PR?

@AllanChain Awesome works! You shouldn't do that. It will be built with the next plugin SDK release ;-)

Copy link
Collaborator

@xyhp915 xyhp915 left a comment

Choose a reason for hiding this comment

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

LGTM.

@xyhp915 xyhp915 requested review from andelf and tiensonqin August 30, 2023 04:08
@tiensonqin tiensonqin merged commit 2eaa116 into logseq:master Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugins can't be disabled if error thrown in beforeunload

3 participants