Skip to content

fix(app): support web startup without Array.toSorted - #65360

Open
jipeng6036-del wants to merge 1 commit into
anomalyco:devfrom
jipeng6036-del:fix/65348-web-tosorted
Open

jipeng6036-del wants to merge 1 commit into
anomalyco:devfrom
jipeng6036-del:fix/65348-web-tosorted

Conversation

@jipeng6036-del

Copy link
Copy Markdown

Issue for this PR

Closes #65348

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Load a copy-and-sort fallback from the existing web polyfills when the browser lacks Array.prototype.toSorted. Plugin command registration can then finish on older WebViews.

Thanks to @ddingning for identifying the startup failure and confirming the workaround.

How did you verify your code works?

With toSorted removed before navigation, the original app shows the reported TypeError. The built app opens Home and shows the expected project. The Home suite passed all 23 tests, and the new case passed 10 repetitions with five workers. App unit and browser tests and the Linux repo check passed. The separate E2E typecheck reports the same 196 diagnostics on both revisions.

Screenshots / recordings

The regression checks the app's startup and the project list in Chromium.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as intended. I built the app on the base and on this pull request, served it with opencode serve from source, and loaded it in headless Chromium with Array.prototype.toSorted deleted before any page script ran. On the base the app shows the "Something went wrong" screen. With this change it shows "Connect to a server", the same as it does with the native method. The new e2e test fails on the base and passes here. polyfills.test.ts and tsc -b pass.

The fallback behaves like native toSorted for empty slots, undefined and a non-function comparator. It is non-enumerable and leaves the original array unchanged. The app's other newer array calls (findLast, findLastIndex) are already supported by the browsers affected here.

The public API is unchanged.

No blocking concerns.

Before

After

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: toSorted is not a function on old Android WebView

1 participant