kubernetes-graceful-shutdown-example
kubernetes-graceful-shutdown-example copied to clipboard
serverDestroy always fails with error
On shutdown, when serverDestroy is called, it always fails with this error:
Error happened during graceful shutdown TypeError: Cannot read property 'apply' of undefined
The problem seems to be that serverDestroy is defined like this:
const serverDestroy = promisify(server.destroy, server)
But server.destroy does not take a callback (anymore?):
destroy(error?: Error): void;
Looks like the callback was never meant to be used externally: https://github.com/nodejs/node/pull/32809
Replacing server.destroy with server.close seems to work correctly.