I am firing a query using on the react front-end which in turn triggers a long task on the server. The task is triggered again on the server (no fire visible on the network tab on front-end) and after some time the front-end throws a network error - failed to fetch.
All short task queries/mutations work just fine. I tried useLazyQuery, refetch from useQuery and creating a custom useLazyQuery as well. Same result for all as well as from the graphql playground.
I'm using apollo-server-express and the timeout set is 1200s. Following is my server.js
import express from "express";
import { ApolloServer } from "apollo-server-express";
import mongoose from "mongoose";
import fs from "fs";
import { resolvers } from "./graphql/resolvers/resolvers.js";
import { typeDefs } from "./GraphQL/typeDefs";
const cors = require("cors");
const startServer = async () => {
console.log("[Server] Creating Express Server");
var dir = "src/graphql/resolvers/audiofiles";
if (!fs.existsSync(dir)) {
console.log("[Server] Creating directory ", dir);
fs.mkdirSync(dir);
}
const app = express();
app.use(cors());
console.log("[Server] Creating ApolloServer");
const apollo = new ApolloServer({
typeDefs,
resolvers
});
apollo.applyMiddleware({ app });
console.log("[Server] Connecting to MongoDB");
await mongoose
.connect("mongodb://localhost:27017/database",
{
useNewUrlParser: true
}
)
.then(
app.listen(
{
port: 4000,
origin: {
requestTimeout: "1200s"
}
},
() =>
console.log(`Server ready at http://****:4000${apollo.graphqlPath}`)
)
)
.catch((err) => console.log(err));
};
startServer();
This is not a cors issue as it works for other queries but and for long tasks, fails after some time. My front-end apollo-client has a fetch policy "no-cache" and I don't see a second call in the network tab. I think there would've been a third one if the front-end didn't get a network error. I'm sure this has got something to do with the front-end.
I want to understand whether this is a front-end problem or a server side problem. What is a good way to diagnose the problem?