Commit 75ae702
committed
refactor(browser): gettabbyid returns undefined when tab not found despite non-nullable return type
`Array.prototype.find()` returns `undefined` when no element matches, but the function declares its return type as `Promise<TargetInfo>` (non-nullable). The `as TargetInfo` cast silences the compiler but doesn't prevent `undefined` at runtime. Any caller accessing properties on the result (e.g., `tab.url`, `tab.webSocketDebuggerUrl`) will get a TypeError: "Cannot read properties of undefined". This is especially likely during race conditions where a tab closes between `getTabs` and the caller using the result.
Affected files: utils.ts
Signed-off-by: kumburovicbranko682-boop <295886834+kumburovicbranko682-boop@users.noreply.github.com>1 parent 526d487 commit 75ae702
1 file changed
Lines changed: 5 additions & 1 deletion
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
0 commit comments