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

issue on syscall timeout - TypeError: error.text is not a function #4

Open
boly38 opened this issue Nov 30, 2023 · 0 comments
Open

Comments

@boly38
Copy link

boly38 commented Nov 30, 2023

Hi,
I found an issue ("pantry-node": "^0.1.3") while trying to use pantry when the service is not available (ETIMEOUT negative case):

here is applicative logs

PANTRY DIST ERROR {"errno":-4039,"code":"ETIMEDOUT","syscall":"connect","address":"redacted:redacted:redacted::6815:1b11","port":443}
11-30 20:48:46.551 | debug | TypeError: error.text is not a function
    at Request.perform (C:\WORK\redacted\node_modules\pantry-node\dist\pantry.js:37:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Pantry.details (C:\WORK\redacted\node_modules\pantry-node\dist\pantry.js:86:24)

I just add one line to the dist\pantry.js(l29) node_modules file to understand the response format an related error in that case:

    static async perform(route, method, parseJSON, payload = {}) {
      try {
        const responseFormat = parseJSON ? 'json' : 'string';
        const action = bent(method, responseFormat);
        const response = await action(Request.path(route), payload);
        return response
      } catch (error) {
        console.log("PANTRY DIST ERROR " + JSON.stringify(error))
        const errorMessage = await error.text();
        throw errorMessage
      }
    }

it seems that there is a need to undertake/catch this kind of error (without text) to fix that case.

NB: another more general remark about error/success nodejs lib response desing for end-user: a short code attrbute may be a good improvement to manipulate positive/negative cases in a more easy way (ex. OK, TIMEOUT, NOT_FOUND etc..)

Thanks for this project (having free resource) :) 👍

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

1 participant