Use Node's built-in fetch instead of node-fetch (punycode DeprecationWarning, #219)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 54/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- backend-api-design
Línea de trabajo
Read index.ts and jws_verification.ts, then inspect the three test files that import Response from node-fetch and the OCSP fetch mock. Check how the protected makeFetchRequest return type is used by subclasses before changing it. Done means the library uses Node's global fetch APIs, preserves the documented request and response behavior, and passes the build and tests described in the issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
On Node 22 and later, loading the library can print:
(node:8) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
[email protected] depends on [email protected], which depends on [email protected]. whatwg-url/lib/url-state-machine.js and tr46/index.js both call require("punycode"), which loads Node's deprecated built-in module.
When the library runs straight from node_modules, Node does not print the warning, because it skips DEP0040 for code under node_modules. When it is bundled, for example by esbuild for AWS Lambda, those require calls end up in the bundle file. The bundle is outside node_modules, so the warning shows up on every cold start. Lambda logs stderr at ERROR level, so in our case this was the only ERROR line on the functions that use the library.
#219 reported the same warning and was closed because node-fetch 3 is ESM-only and the library is CommonJS. That reason still holds for node-fetch 3. This issue proposes a different route.
Proposal
The README lists Node 22+ as the requirement, and Node has shipped fetch, Headers, Response and AbortSignal.timeout as globals since Node 18. The library could use those and drop node-fetch and @types/node-fetch from its dependencies. It stays CommonJS.
I have a working branch. The library changes are small:
index.tsandjws_verification.tsstop importingnode-fetchand use the globalfetchandHeaders.- The
timeoutoption, which only exists in node-fetch, becomessignal: AbortSignal.timeout(...), with the same 30 s values. response.buffer()in the OCSP check becomesBuffer.from(await response.arrayBuffer()).response.headers.raw()inmakeRequestis replaced byheaders.forEach, withheaders.getSetCookie()forset-cookie.- The error body in
makeRequestis read asunknownand narrowed with a type guard (see point 4 below). - Three test files stop importing
Responsefromnode-fetch, and the OCSP mock spies onglobalThis.fetch.
With these changes tsc -p tsconfig.build.json passes and all 456 tests pass on Node 22, 24 and 26. I also ran the built library against a local HTTP server to check a request with a Buffer body, a 429 response with Retry-After, and the request timeout.
It also removes form-data from the dependency tree. It currently comes in through @types/node-fetch, and [email protected] has an open advisory (GHSA-hmw2-7cc7-3qxx).
Compatibility
This is why I am opening an issue before a PR.
makeFetchRequestis protected and can be overridden. Its return type changes from node-fetch'sResponseto the globalResponse. A subclass that builds a node-fetchResponsewould no longer type-check. Two of the test files do this today.APIException.headerschanges slightly. The Fetch standard trims leading and trailing whitespace from header values, so one test case (Retry-After: " ") now gets[""]. Over a real connection Node's HTTP parser already trims it, so the value is the same either way. A header sent more than once comes back as one comma-joined entry (["a, b"]rather than["a", "b"]), exceptset-cookie, which stays split.- A request that times out in
AppStoreServerAPIClientnow rejects with aTimeoutErrorDOMExceptionrather than node-fetch'sFetchError. InSignedDataVerifierit is still wrapped asRETRYABLE_VERIFICATION_FAILURE, as before. - Native
response.json()returnsPromise<unknown>where node-fetch returnedPromise<any>, so the error path inmakeRequestnow checks the body's types before building theAPIException.errorCodeis used only when it is a number anderrorMessageonly when it is a string; anything else becomesnull. The API always sends a numericerrorCode, so the visible difference is that a missingerrorMessageis nownullinstead ofundefined, which matches the declaredstring | nulltype.
If point 1 is a problem for a minor release, this could wait for the next major version.
Would you accept a PR along these lines? I can open it against main.
- Lenguaje dominante
- TypeScript
- Estrellas
- 388
- Forks
- 88
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apple/app-store-server-library-node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
NotificationHistoryResponseValidator uses the response validator for history items and accepts malformed item fieldsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Cloudflare Workers (nodejs_compat): SignedDataVerifier passes with online checks; two non-crypto blockers remainPosiblemente ocupada @vishalhabib99 la tomó hace 4 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 32/100
apple/app-store-server-library-node#476 · 1 comentario · 1 reacción ·
-
Abort OCSP requests when the response times outPosiblemente ocupada @TorinAsakura la tomó hace 71 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
-
Subscription status response validators omit validation of data and nested lastTransactionsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 84/100
Todos los issues de apple/app-store-server-library-node
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[Bug]: Search input loses focus while typing on the Inventory, Reservations and Locations lists (view_configurations enabled)Posiblemente ocupada @medusa-os-bot la tomó hoy. Abiertostatus: needs triaging type: bug version: 2.0
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
medusajs/medusa#17886 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
marimo-team/marimo#11949 ·
Los mantenedores suelen responder en 1 día
-
bug server-time v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
modelcontextprotocol/servers#5559 ·
Los mantenedores suelen responder en 1 día
-
D1 Time Travel restore help advertises 30 days without a plan qualifierPosiblemente ocupada @akhil9tiet la tomó hoy. Abiertobug package:wrangler product:d1
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
cloudflare/workers-sdk#17000 · 2 comentarios ·
Los mantenedores suelen responder en 1 día