accessibility-insights-web icon indicating copy to clipboard operation
accessibility-insights-web copied to clipboard

TabStore crashes and breaks background initialization when given an invalid URL

Open dbjorge opened this issue 3 years ago • 2 comments
trafficstars

Describe the bug

If TabStore ever tries to handle a tab-updated event that involves a URL which cannot be parsed by new URL(), it emits an unhandled exception which prevents the completion of background initialization. The stack looks like:

TypeError: Failed to construct 'URL': Invalid URL
    at TabStore.originsMatch (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:89756:43)
    at TabStore.onExistingTabUpdated (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:89737:19)
    at chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:86744:11
    at Array.forEach (<anonymous>)
    at _Action.invoke (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:86743:24)
    at TabActionCreator.onExistingTabUpdated [as insights/tab/existingTabUpdated] (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:89074:44)
    at Interpreter.interpret (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:87138:67)
    at TabContextManager.interpretMessageForTab (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:83838:30)
    at TargetPageController.interpretMessageAsync (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:90460:47)
    at TargetPageController.sendTabUrlUpdatedAction (chrome-extension://hbcplehnakffdldhldncjlnbpfgogbem/bundle/background.bundle.js:90442:18)

Once in this state, the whole extension is broken and just shows loading spinners until the next time the background is torn down and re-initialized.

To Reproduce

Not sure how to reproduce reliably; I encountered the issue locally by accident. We see it pretty regularly in telemetry against insider/canary builds, though; team members with staging telemetry access can use this query to search for instances (there are 46 in the last 30d):

customEvents
| where timestamp > ago(30d)
| where name == 'unhandledError'
| project timestamp, errorType=customDimensions.errorType, source=customDimensions.source, message=customDimensions.message, stackTrace=customDimensions.stackTrace
| where message contains 'Background initialization failed'

CodePen repro example

n/a

Expected behavior

A tab with an invalid URL shouldn't prevent the whole application from initializing; the app should still be functional against other tabs.

Screenshots

n/a

Context (please complete the following information)

  • OS Name & Version: Windows 21H1 (22000.795)
  • AI-Web Version & Environment: Canary 2022.7.13.1526
  • Browser Version: Edge 103.0.1264.49 (stable)
  • Target Page: Unsure

Are you willing to submit a PR?

Yes

Did you search for similar existing issues?

Yes

Additional context

n/a

dbjorge avatar Jul 14 '22 23:07 dbjorge

This issue has been marked as ready for team triage; we will triage it in our weekly review and update the issue. Thank you for contributing to Accessibility Insights!

ghost avatar Jul 18 '22 17:07 ghost

@dbjorge was this fixed by #5754?

ferBonnin avatar Jul 25 '22 23:07 ferBonnin