fix: Make sure if header is set already, it isn't set again (#12194)

This commit is contained in:
Hariom Balhara 2023-11-02 17:52:16 +05:30 committed by GitHub
parent 9348279818
commit d8356e9a5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,9 @@ export function defaultResponder<T>(f: Handle<T>) {
performance.mark("Start");
const result = await f(req, res);
ok = true;
if (result) res.json(result);
if (result && !res.writableEnded) {
res.json(result);
}
} catch (err) {
console.error(err);
const error = getServerErrorFromUnknown(err);