Skip to content

Commit

Permalink
fix: AbortController and AbortSignal.timeout Polyfill (#10815)
Browse files Browse the repository at this point in the history
- Introduced a polyfill for AbortController and AbortSignal.timeout,
enabling support for aborting operations in environments that do not
natively support these features.
- This addition allows developers to use AbortController to manage
request cancellations more effectively, improving error handling and
resource management.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces the `abortcontroller-polyfill` to enhance
compatibility with the `AbortSignal` API in the application. It also
updates package dependencies and modifies the `package.json` to include
the new polyfill.

### Detailed summary
- Added `abortcontroller-polyfill` import in
`apps/web/src/pages/_app.tsx`.
- Implemented a timeout function in
`apps/web/src/utils/abortcontroller-polyfill.ts`.
- Updated `pnpm-lock.yaml` to include `abortcontroller-polyfill` version
1.7.5.
- Updated `@noble/curves` from 1.4.0 to 1.6.0 in `pnpm-lock.yaml`.
- Updated `ws` from 8.17.1 to 8.18.0 in `pnpm-lock.yaml`.
- Added `@kyberswap/pancake-liquidity-widgets` version 0.1.1 to
`apps/web/package.json`.
- Removed `@kyberswap/pancake-liquidity-widgets` from previous
dependencies in `apps/web/package.json`.
- Added `abortcontroller-polyfill` version 1.7.5 to
`apps/web/package.json`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
chef-ryan authored Oct 14, 2024
1 parent 0416422 commit ed5e430
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@datadog/browser-rum": "^5.8.0",
"@gelatonetwork/limit-orders-lib": "^4.1.0",
"@gnosis.pm/safe-apps-wagmi": "^1.2.0",
"@kyberswap/pancake-liquidity-widgets": "0.1.1",
"@next/bundle-analyzer": "13.0.7",
"@orbs-network/twap-ui": "0.11.2",
"@orbs-network/twap-ui-pancake": "0.11.2",
Expand Down Expand Up @@ -78,7 +79,6 @@
"@pancakeswap/v3-sdk": "workspace:*",
"@pancakeswap/wagmi": "workspace:*",
"@pancakeswap/widgets-internal": "workspace:*",
"@kyberswap/pancake-liquidity-widgets": "0.1.1",
"@pythnetwork/pyth-evm-js": "^1.29.2",
"@reduxjs/toolkit": "^1.9.1",
"@sentry/nextjs": "^8.16.0",
Expand All @@ -92,6 +92,7 @@
"@web3inbox/core": "1.2.0",
"@web3inbox/react": "1.2.0",
"@yornaath/batshit": "^0.9.0",
"abortcontroller-polyfill": "1.7.5",
"ajv": "^6.12.3",
"bignumber.js": "^9.0.0",
"bottleneck": "^2.19.5",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Head from 'next/head'
import Script from 'next/script'
import { Fragment } from 'react'
import { PersistGate } from 'redux-persist/integration/react'
import 'utils/abortcontroller-polyfill'
import { V4CakeIcon } from 'views/Home/components/V4CakeIcon'

import { ZKSyncAirdropModalWithAutoPopup } from 'components/ClaimZksyncAirdropModal'
Expand Down
10 changes: 10 additions & 0 deletions apps/web/src/utils/abortcontroller-polyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'

if (!('timeout' in AbortSignal)) {
const timeoutFN = (ms: number) => {
const controller = new AbortController()
setTimeout(() => controller.abort(), ms)
return controller.signal
}
;(AbortSignal as any).timeout = timeoutFN
}
7 changes: 5 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ed5e430

Please sign in to comment.