-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
Search first
- I searched and no similar issues were found
What Happened?
If a plugin has beforeunload hook which throws an error, clicking disable won't really disable the plugin, and the plugin will be enabled again after the app restart.
Reproduce the Bug
- Create a simple plugin
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Logseq selection bug</title>
</head>
<body>
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/@logseq/libs"></script>
<script src="./index.js"></script>
</body>
</html>package.json
{
"name": "logseq-unload-bug",
"version": "1.0.0",
"description": "",
"main": "index.html",
"logseq": {
"id": "logseq-unload-bug"
},
"license": "MIT"
}index.js
function main () {
logseq.beforeunload(() => {
throw "I won't unload!!!"
})
}
logseq.ready(main).catch(console.error)- Disable the plugin.
- Restart app. The plugin is not disabled.
Expected Behavior
The plugin will be disabled despite it throwing an error in beforeunload
Screenshots
No response
Desktop or Mobile Platform Information
Linux, Desktop App, v0.9.15
Additional Context
Maybe just add try{}catch{}?
logseq/libs/src/LSPlugin.core.ts
Line 467 in 361d08d
| await this.load() |
logseq/libs/src/LSPlugin.core.ts
Line 475 in 361d08d
| await this.unload() |
Are you willing to submit a PR? If you know how to fix the bug.
- I'm willing to submit a PR (Thank you!)