Commit c8bfcf3
committed
fix(menus): observe Browser.tabs.sendMessage promises in onClickMenu
`Browser.tabs.sendMessage()` (via webextension-polyfill) returns a Promise
that commonly rejects in normal extension usage — when no content script
is listening yet, on restricted pages (chrome://, about:, etc.), or after
an extension reload makes old content scripts stale. Both call sites in
onClickMenu were leaving the returned Promise unobserved, so a rejection
would surface as an unhandled rejection in the background script.
Attach a .catch() to both sendMessage call sites (selectionTools branch
and the menuConfig genPrompt branch), mirroring the handling already
applied to Browser.tabs.query() and the menu/command actions in this PR.
This completes the unhandled-rejection story for the whole onClickMenu
handler.
Co-Authored-By: Octopus <liyuan851277048@icloud.com>1 parent 2a82410 commit c8bfcf3
1 file changed
Lines changed: 23 additions & 8 deletions
File tree
- src/background
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| |||
0 commit comments