Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout and crash when doing PUT request but GET works fine #198

Closed
xrd opened this issue May 20, 2023 · 4 comments
Closed

Timeout and crash when doing PUT request but GET works fine #198

xrd opened this issue May 20, 2023 · 4 comments

Comments

@xrd
Copy link

xrd commented May 20, 2023

I have a nodejs (v18) pocketbase script that is crashing when I attempt to update the model. The error is a timeout. But, the GET request works fine.

ClientResponseError 0: Something went wrong while processing your request.
    at new ClientResponseError (file:///app/www/node_modules/pocketbase/dist/pocketbase.es.mjs:1:2306)
    at file:///app/www/node_modules/pocketbase/dist/pocketbase.es.mjs:1:45357
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  url: '',
  status: 0,
  response: {},
  isAbort: false,
  originalError: TypeError: fetch failed
      at Object.fetch (node:internal/deps/undici/undici:11457:11)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    cause: ConnectTimeoutError: Connect Timeout Error
        at onConnectTimeout (node:internal/deps/undici/undici:8422:28)
        at node:internal/deps/undici/undici:8380:50
        at Immediate._onImmediate (node:internal/deps/undici/undici:8411:13)
        at process.processImmediate (node:internal/timers:476:21) {
      code: 'UND_ERR_CONNECT_TIMEOUT'
    }
  }
}

(Node.js v18.16.0)

Right at the crash I get a stack trace with this:

file:///app/www/node_modules/pocketbase/dist/pocketbase.es.mjs:1 (then lots and lots of JS code from the pocketbase library).

This app is running inside dokku (and the request is running as a cron job inside the container). I would have assumed that this is an issue with the internal ports and external ports not being wired together correctly and the docker host not sending traffic to the correct backend (pocketbase) container, but the fact that a GET request works makes my head spin.

If I run things outside the container, it works fine. It clearly is an issue with the way traffic is being routed between containers and the nginx front end, but I'm really stumped as to why GET works but PUT does not.

@ganigeorgiev
Copy link
Member

ganigeorgiev commented May 20, 2023

Hm, I'm not sure what is causing the error. Since it has a status: 0 it doesn't seem to reach the PocketBase server and it is probably directly rejected in the request running env. Googling the error code I stumbled on nodejs/undici#1531.

If you are using localhost in the JS SDK initialization try to replace it with the fixed IPv4 or IPv6 address, eg. 127.0.0.1 (see #21). If not, make sure that the correct url address is used in the JS SDK constructor (aka. check for trailing spaces, incorrect port, etc.).

If the above doesn't help, you can also try to remove the undici in order to use the native fetch implementation that comes with Node 18. Ignore this, I just found out that the Node 18 implementation is actually based on undici.


why GET works but PUT does not

Is this via the same JS SDK instance?
Could you provide a code sample with the update request?

@xrd
Copy link
Author

xrd commented May 20, 2023

Sure, the code is just this for the update: pb.collection('subscriptions').update(id, { kids: newKids} );

I'll review these notes, thank you!

@ganigeorgiev
Copy link
Member

I'll close the issue for now since I don't think it is related to the JS SDK and I'm not sure how to reproduce it.

If you weren't able to find the reason for the error, feel free to provide a minimal reproducible steps/repo and I'll try to investigate it.

@98mux
Copy link

98mux commented Aug 30, 2024

For people who stumbled on this error recently and is using vercel (Like I did), apparently they are having some problems:

vercel/vercel#11692

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

No branches or pull requests

3 participants