From 1c86f43f8451d2ecbe9f4099bdbc3031a9b56ecc Mon Sep 17 00:00:00 2001 From: Jordane Belanger Date: Tue, 17 Nov 2020 13:23:56 -0500 Subject: [PATCH] Update README.md Fix Vapor 4 metrics endpoint example leading to an NIO leaky promise error at runtime in debug mode. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cb63ae1..9455d83 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,13 @@ By default, this should be accessible on your main serving port, at the `/metric ```swift app.get("metrics") { req -> EventLoopFuture in let promise = req.eventLoop.makePromise(of: String.self) - try MetricsSystem.prometheus().collect(into: promise) + DispatchQueue.global().async { + do { + try MetricsSystem.prometheus().collect(into: promise) + } catch { + promise.fail(error) + } + } return promise.futureResult } ```