Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Promise #59

Open
deweve opened this issue Jul 6, 2021 · 3 comments

Comments

@deweve
Copy link

deweve commented Jul 6, 2021

Hi,

I'm using the middleware but when I call the endpoint I receive this exececption

TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Promise

at Function.byteLength (buffer.js:728:11)
at chunkLength (/Users/etiennedewever/work/Polyconseil/coviflex/coviflex-api/node_modules/compression/index.js:245:14)
at ServerResponse.end (/Users/etiennedewever/work/Polyconseil/coviflex/coviflex-api/node_modules/compression/index.js:100:20)

This is due because it sending a promise to res.end

It just need to be await first then send

@deweve
Copy link
Author

deweve commented Jul 6, 2021

I cannot push the modification :

The solution :

Index.js line 157

    res.set('Content-Type', Prometheus.register.contentType);
    const metrics = await Prometheus.register.metrics();
    return res.end(metrics);

@joao-fontenele
Copy link
Owner

hello @deweve, what version are you using? it seems to have an await already in the code in the following line

@deweve
Copy link
Author

deweve commented Jul 7, 2021

It seems I'm using the 1.0 version. I've just realised the await in the return. I can check if the problem persists

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

No branches or pull requests

2 participants