https://supertokens.com/ logo
#support-questions
Title
# support-questions
g

gadi

02/02/2022, 10:00 AM
Sure, for now I fixed it by patching apollo-server-express as following:
Copy code
diff --git a/dist/ApolloServer.js b/dist/ApolloServer.js
index 203eef5bc362cf6ed46933726b08c6aeb2cf7277..3cf2d07e6a60c534cf5dd56b29c119a0d032071a 100644
--- a/dist/ApolloServer.js
+++ b/dist/ApolloServer.js
@@ -80,6 +80,9 @@ class ApolloServer extends apollo_server_core_1.ApolloServerBase {
                 query: req.method === 'POST' ? req.body : req.query,
                 request: (0, apollo_server_core_1.convertNodeHttpToRequest)(req),
             }).then(({ graphqlResponse, responseInit }) => {
+                if (res.headersSent) {
+                    return;
+                }
                 if (responseInit.headers) {
                     for (const [name, value] of Object.entries(responseInit.headers)) {
                         res.setHeader(name, value);
@@ -96,6 +99,9 @@ class ApolloServer extends apollo_server_core_1.ApolloServerBase {
                 if (!(0, apollo_server_core_1.isHttpQueryError)(error)) {
                     return next(error);
                 }
+                if (res.headersSent) {
+                    return;
+                }
                 if (error.headers) {
                     for (const [name, value] of Object.entries(error.headers)) {
                         res.setHeader(name, value);