Created
February 22, 2025 13:04
-
-
Save manzil-infinity180/a761e210db08e477d2a72973e3037e44 to your computer and use it in GitHub Desktop.
TypeError: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypeError: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Promise | |
at write_ (node:_http_outgoing:945:11) | |
at ServerResponse.end (node:_http_outgoing:1102:5) | |
at /Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/dist/index.js:58:17 | |
at Layer.handle [as handle_request] (/Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/layer.js:95:5) | |
at next (/Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/route.js:149:13) | |
at Route.dispatch (/Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/route.js:119:3) | |
at Layer.handle [as handle_request] (/Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/layer.js:95:5) | |
at /Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/index.js:284:15 | |
at Function.process_params (/Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/index.js:346:12) | |
at next (/Users/rahulxf/JourneyToXYZ/socket.io-prometheus-metrics/node_modules/express/lib/router/index.js:280:10) | |
---------------------------------------------------------------------------- | |
private initServer() { | |
this.express = express(); | |
this.expressServer = this.express.listen(this.options.port); | |
this.express.get(this.options.path, async (_req: express.Request, res: express.Response) => { | |
try { | |
const metrics = await this.register.metrics(); // Await the Promise | |
res.set('Content-Type', this.register.contentType); | |
res.end(metrics); // metrics is now a string | |
} catch (error) { | |
res.status(500).end('Error collecting metrics'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment