I am using POST api built by different team in our application and since its taking more than 1 minute to return a response our graphql mutation is returning Internal_Server_error (https://www.apollographql.com/docs/apollo-server/v2/data/errors#internal_server_error). We are using @types/node-fetch: "1.6.9" to consume these endpoints. I tried to set the timeout in the options object of the request as mentioned in github (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node-fetch/index.d.ts#L59) but Apollo server is still giving Internal_Server_Error. I tried using AbortController but our application is currently using Node 12.x.x and abort controller requires node 14.x.x.
I just want to know if there is anything we can do from our end to make apollo server wait for the request to be successful which should take 1 minute and 10 seconds and not give out 504.
This is how I am setting the timeout
import fetch from "node-fetch";
const res = await fetch(`${this.baseURL}/api/v1/dummy?${query}`,
{
method: "POST",
body: JSON.stringify({
-----
-----
}),
timeout: 60000,
headers: {"Content-Type": "application/json"},
});
Value of res variable after running the mutation:
Body {
url: 'secret_url',
status: 504,
statusText: 'Gateway Time-out',
headers: Headers {
_headers: {
server: [Array],
date: [Array],
'content-type': [Array],
'content-length': [Array],
connection: [Array],
'set-cookie': [Array]
}
},
ok: false,
body: PassThrough {
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: [Object], tail: [Object], length: 1 },
length: 132,
pipes: null,
pipesCount: 0,
flowing: null,
ended: true,
endEmitted: false,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
emitClose: true,
autoDestroy: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: null
},
readable: true,
_events: [Object: null prototype] { prefinish: [Function: prefinish] },
_eventsCount: 1,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: true,
ended: true,
finished: true,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: true,
errorEmitted: false,
emitClose: true,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object]
},
writable: false,
allowHalfOpen: true,
_transformState: {
afterTransform: [Function: bound afterTransform],
needTransform: false,
transforming: false,
writecb: null,
writechunk: null,
writeencoding: 'buffer'
},
[Symbol(kCapture)]: false
},
bodyUsed: false,
size: 0,
timeout: 180000,
_raw: [],
_abort: false
}
Response from swagger-ui