Skip to content

fix: replace Array.prototype.at() for broader browser compatibility#3985

Draft
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/array-at-compatibility
Draft

fix: replace Array.prototype.at() for broader browser compatibility#3985
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/array-at-compatibility

Conversation

@sentry

@sentry sentry Bot commented May 30, 2026

Copy link
Copy Markdown

Description

This PR addresses a TypeError: e.at is not a function occurring on older iOS Safari versions (e.g., iOS 12.5.8 / Mobile Safari 12.1.2).

The root cause was the use of Array.prototype.at() in several places, which is an ES2022 feature not supported in these older browsers.

The fix involves replacing all instances of Array.prototype.at(-n) with equivalent bracket notation (arr[arr.length - n]) or arr.slice(-1)[0]) to ensure compatibility across a wider range of browsers without introducing polyfills.

Code Example

// Before
const lastElement = myArray.at(-1);
const secondLastElement = myArray.at(-2);

// After
const lastElement = myArray[myArray.length - 1];
const secondLastElement = myArray[myArray.length - 2];
// or for the last element
const lastElement = myArray.slice(-1)[0];

Notable Changes

  • Problem: TypeError: e.at is not a function encountered on older iOS Safari versions (e.g., iOS 12.5.8 / Mobile Safari 12.1.2).
  • Cause: Usage of Array.prototype.at(), an ES2022 feature, which is not supported in these older browsers.
  • Solution: Replaced all instances of Array.prototype.at(-n) with compatible alternatives like arr[arr.length - n] or arr.slice(-1)[0].
  • Affected files:
    • src/shared/ContentsTable/utils/adjustListIfUpDir.tsx
    • src/shared/utils/url.ts
    • src/pages/RepoPage/BundlesTab/BundleContent/AssetsTable/AssetsTable.tsx
    • src/pages/RepoPage/CoverageTab/OverviewTab/hooks/useRepoCoverageTimeseries.ts

Screenshots

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes GAZEBO-17YX

@sentry

sentry Bot commented May 30, 2026

Copy link
Copy Markdown
Author

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.73%. Comparing base (2271ee2) to head (09d88fb).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3985   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files         826      826           
  Lines       15129    15129           
  Branches     4365     4357    -8     
=======================================
  Hits        14938    14938           
  Misses        184      184           
  Partials        7        7           
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <100.00%> (ø)
...Tab/OverviewTab/hooks/useRepoCoverageTimeseries.ts 100.00% <100.00%> (ø)
...c/shared/ContentsTable/utils/adjustListIfUpDir.tsx 100.00% <100.00%> (ø)
src/shared/utils/url.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <100.00%> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <100.00%> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2271ee2...09d88fb. Read the comment docs.

@sentry

sentry Bot commented May 30, 2026

Copy link
Copy Markdown
Author

Bundle Report

Changes will increase total bundle size by 53 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.87MB 22 bytes (0.0%) ⬆️
gazebo-production-esm 5.96MB 31 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: gazebo-production-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index.*.js 2 bytes 90.03kB 0.0%
assets/index.*.js 12 bytes 53.6kB 0.02%
assets/RawFileViewer.*.js 17 bytes 127.16kB 0.01%

Files in assets/index.*.js:

  • ./src/pages/RepoPage/CoverageTab/OverviewTab/hooks/useRepoCoverageTimeseries.ts → Total Size: 1.73kB

Files in assets/index.*.js:

  • ./src/pages/RepoPage/BundlesTab/BundleContent/AssetsTable/AssetsTable.tsx → Total Size: 13.97kB

Files in assets/RawFileViewer.*.js:

  • ./src/shared/ContentsTable/utils/adjustListIfUpDir.tsx → Total Size: 715 bytes

  • ./src/shared/utils/url.ts → Total Size: 620 bytes

view changes for bundle: gazebo-production-system

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-legacy.*.js -7 bytes 84.76kB -0.01%
assets/index-legacy.*.js 12 bytes 49.42kB 0.02%
assets/RawFileViewer-legacy.*.js 17 bytes 127.38kB 0.01%

Files in assets/index-legacy.*.js:

  • ./src/pages/RepoPage/CoverageTab/OverviewTab/hooks/useRepoCoverageTimeseries.ts → Total Size: 1.73kB

Files in assets/index-legacy.*.js:

  • ./src/pages/RepoPage/BundlesTab/BundleContent/AssetsTable/AssetsTable.tsx → Total Size: 13.97kB

Files in assets/RawFileViewer-legacy.*.js:

  • ./src/shared/ContentsTable/utils/adjustListIfUpDir.tsx → Total Size: 715 bytes

  • ./src/shared/utils/url.ts → Total Size: 634 bytes

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #3985   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files         826      826           
  Lines       15129    15129           
  Branches     4357     4357           
=======================================
  Hits        14938    14938           
  Misses        184      184           
  Partials        7        7           
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <100.00%> (ø)
...Tab/OverviewTab/hooks/useRepoCoverageTimeseries.ts 100.00% <100.00%> (ø)
...c/shared/ContentsTable/utils/adjustListIfUpDir.tsx 100.00% <100.00%> (ø)
src/shared/utils/url.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <100.00%> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <100.00%> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2271ee2...09d88fb. Read the comment docs.

@codecov-public-qa

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.73%. Comparing base (2271ee2) to head (09d88fb).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #3985   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files         826      826           
  Lines       15129    15129           
  Branches     4365     4357    -8     
=======================================
  Hits        14938    14938           
  Misses        184      184           
  Partials        7        7           
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <100.00%> (ø)
...Tab/OverviewTab/hooks/useRepoCoverageTimeseries.ts 100.00% <100.00%> (ø)
...c/shared/ContentsTable/utils/adjustListIfUpDir.tsx 100.00% <100.00%> (ø)
src/shared/utils/url.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <100.00%> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <100.00%> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2271ee2...09d88fb. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codecov-qa

codecov-qa Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.73%. Comparing base (2271ee2) to head (09d88fb).

@@           Coverage Diff           @@
##             main    #3985   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files         826      826           
  Lines       15129    15129           
  Branches     4365     4365           
=======================================
  Hits        14938    14938           
  Misses        184      184           
  Partials        7        7           
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <100.00%> (ø)
...Tab/OverviewTab/hooks/useRepoCoverageTimeseries.ts 100.00% <100.00%> (ø)
...c/shared/ContentsTable/utils/adjustListIfUpDir.tsx 100.00% <100.00%> (ø)
src/shared/utils/url.ts 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <100.00%> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <100.00%> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2271ee2...09d88fb. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

0 participants