25d064f812
This ncc's some remaining dependencies bringing us under 20 install time dependencies (including nested dependencies), this also reduces install size by another `2.75 MB`. A follow-up PR will investigate a custom install script for our swc packages to allow us to remove the `optionalDependencies` which is slowing down install time as well. x-ref: https://github.com/vercel/next.js/pull/32679 x-ref: https://github.com/vercel/next.js/pull/32627 x-ref: https://github.com/vercel/next.js/issues/31887 x-ref: https://github.com/vercel/styled-jsx/pull/770
31 lines
802 B
TypeScript
31 lines
802 B
TypeScript
import retry from 'next/dist/compiled/async-retry'
|
|
import fetch from 'next/dist/compiled/node-fetch'
|
|
|
|
export function _postPayload(endpoint: string, body: object) {
|
|
return (
|
|
retry(
|
|
() =>
|
|
fetch(endpoint, {
|
|
method: 'POST',
|
|
body: JSON.stringify(body),
|
|
headers: { 'content-type': 'application/json' },
|
|
timeout: 5000,
|
|
}).then((res) => {
|
|
if (!res.ok) {
|
|
const err = new Error(res.statusText)
|
|
;(err as any).response = res
|
|
throw err
|
|
}
|
|
}),
|
|
{ minTimeout: 500, retries: 1, factor: 1 }
|
|
)
|
|
.catch(() => {
|
|
// We swallow errors when telemetry cannot be sent
|
|
})
|
|
// Ensure promise is voided
|
|
.then(
|
|
() => {},
|
|
() => {}
|
|
)
|
|
)
|
|
}
|