ad4m
ad4m copied to clipboard
Download file from Cloudflare storage is not working
In ad4m app, when downloading file from Cloudflare storage, it first gets the presigned url from cloudflare worker, the url looks like this,
https://c47108641b30e868d9950f1adf09c9b1.r2.cloudflarestorage.com/centralized-bootstrap-store/QmZ16K5HG2RgE6Q8xCC5784HG2KGyKPKtkNmGiDb9YQKZg?X-Amz-Date=20230221T014811Z&X-Amz-Expires=86400&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=38a4e3dfb132248c1b6e07389f77691e%2F20230221%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=33fe05ee13446cc277fb65691da0791f2a5c8600190deae246d8c006a73be0c1
It works when I open the above link in browser, but with Nodejs it's broken with ECONNRESET
error.
with node-fetch
lib, the error is,
FetchError: Invalid response body while trying to fetch https://c47108641b30e868d9950f1adf09c9b1.r2.cloudflarestorage.com/centralized-bootstrap-store/QmZ16K5HG2RgE6Q8xCC5784HG2KGyKPKtkNmGiDb9YQKZg?X-Amz-Date=20230208T172826Z&X-Amz-Expires=86400&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=dbf72009eacc00a2e739260e0105fe65%2F20230208%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=58d40edc56f47946c905bebb871e7f826fdf5673d8e01a679dc4b56ff27fb9ea: Premature close
at Gunzip.<anonymous> (/Users/kaichaosun/github/flux/language-persistence/node_modules/node-fetch/lib/index.js:400:12)
at Gunzip.emit (node:events:525:35)
at Gunzip.emit (node:domain:489:12)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
type: 'system',
errno: 'ERR_STREAM_PREMATURE_CLOSE',
code: 'ERR_STREAM_PREMATURE_CLOSE'
}
with axios
lib, the error is,
cause: Error: aborted
at connResetException (node:internal/errors:705:14)
at TLSSocket.socketCloseListener (node:_http_client:454:19)
at TLSSocket.emit (node:events:525:35)
at TLSSocket.emit (node:domain:489:12)
at node:net:301:12
at TCP.done (node:_tls_wrap:588:7) {
code: 'ECONNRESET'
}
Reproduce steps,
- start VPN (I'm using Astrill VPN)
- checkout code https://github.com/perspect3vism/language-persistence/tree/ECONNRESET
- run npm install and npx ts-node test.ts
Potential related issues, https://github.com/serverless-dns/serverless-dns/issues/115 https://github.com/axios/axios/issues/5267