Commit 327c967
committed
fix(menus): observe sidePanel.open promise to avoid unhandled rejections
The synchronous menuConfig.openSidePanel.action(true, tab) call is
intentional — chrome.sidePanel.open() must run inside the user-gesture
callback or it throws 'sidePanel.open() may only be called in response
to a user gesture'. We don't want to break that.
But the action used to be async, so the chrome.sidePanel.open Promise
was discarded and any rejection (e.g. an invalid tab/window combo)
would surface as an unhandled rejection in the background script.
Two small changes:
- menu-tools/index.mjs: drop the async wrapper and return the
chrome.sidePanel.open() promise directly so the caller can observe it.
- background/menus.mjs: still call the action synchronously (gesture
preserved) but, if it returned a thenable, attach a .catch that logs
the failure instead of letting it become unhandled.
Addresses review feedback from CodeRabbit and gemini-code-assist.1 parent 792b6bc commit 327c967
2 files changed
Lines changed: 13 additions & 5 deletions
File tree
- src
- background
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
| 66 | + | |
69 | 67 | | |
| 68 | + | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
0 commit comments