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

failing without clear reason #1786

Closed
sibelius opened this issue Oct 30, 2023 · 3 comments
Closed

failing without clear reason #1786

sibelius opened this issue Oct 30, 2023 · 3 comments
Labels

Comments

@sibelius
Copy link

Reproduction

it throws this error sometimes when accessing: https://openpix.com.br/pay/84c1b233-855c-4590-9e41-16734290c6a2

FetchError: request to https://openpix.com.br/pay/graphql failed, reason: 
    at ClientRequest.<anonymous> (webpack://index/node_modules/node-fetch/lib/index.js:1491:11)
    at ClientRequest.emit (node:events:523:35)
    at ClientRequest.emit (node:domain:489:12)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:511:28)
    at TLSSocket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

The related to is here

req.on('error', function (err) {
			reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));

			if (response && response.body) {
				destroyStream(response.body, err);
			}

			finalize();
		});

Steps to reproduce the behavior:

Try to access this https://openpix.com.br/pay/84c1b233-855c-4590-9e41-16734290c6a2 and reload or use a anonymous navigator to try to trigger this error

Expected behavior

It should not error

Screenshots

Your Environment

software version
node-fetch 2.7.0
node 20-alpine
npm 10.1.0
Operating System linux

Additional context

How can I get more info on this bug? why reason is not defined?

@sibelius sibelius added the bug label Oct 30, 2023
@OliverJAsh
Copy link

OliverJAsh commented May 17, 2024

I am facing the same issue. We're using error.message and the "reason" is empty. Reduced test case:

import fetch from 'node-fetch';
fetch('http://localhost:1234/regdvfs');

Result:

file:///Users/oliver/Code/unsplash/unsplash-web/node_modules/node-fetch/src/index.js:108
			reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, 'system', error));
			       ^

FetchError: request to http://localhost:1234/regdvfs failed, reason:
    at ClientRequest.<anonymous> (file:///Users/oliver/Code/unsplash/unsplash-web/node_modules/node-fetch/src/index.js:108:11)
    at ClientRequest.emit (node:events:518:28)
    at Socket.socketErrorListener (node:_http_client:500:9)
    at Socket.emit (node:events:518:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  erroredSysCall: undefined
}

error.message:

FetchError: request to http://localhost:1234/regdvfs failed, reason:

I'd expect something like this:

FetchError: request to http://localhost:1234/regdvfs failed, reason: ECONNREFUSED

@sibelius
Copy link
Author

mine was a failing dns service

@OliverJAsh
Copy link

Ah, but I think this is still an issue—that node-fetch doesn't return a more informative error message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants