Lambda function does not finish and times out
See original GitHub issueDescribe the bug Hi there. I’ve been enjoying using Laconia for my lambda-based project, thanks for developing it.
I’m encountering an issue where my Lambda function executes properly, and I can see from the logs that it reaches the final line of the function (the return statement). However lambda doesn’t seem to be aware that the function has finished, so it hangs until the configured timeout and then throws a timeout error.
To Reproduce Here’s a “toy” summary of my code:
import laconia from '@laconia/core';
import myAdaptor from 'Adaptors/myAdaptor';
import getDbConfig from 'Infrastructure/database/getDbConfig';
import connect from 'Infrastructure/database/connect';
const factory1 = async () => ({ dbConfig: await getDbConfig() });
const factory2 = async ({ dbConfig }) => ({
connection: await connect(dbConfig),
});
const app = async (event, { connection }) => {
let result;
try {
result = await connection.performQuery(event);
} catch (err) {
console.error('query error: ', err);
result = err;
}
await connection.end();
console.log('query result: ', result);
return { result: result };
});
export default laconia(myAdapter(app))
.register(factory1)
.register(factory2);
When I invoke this function, the query and logging all happens within 1 second. Then the function waits 10 seconds before returning an error:
{
"errorMessage": "2019-06-08T17:00:51.417Z SOME_UUID Task timed out after 10.00 seconds"
}
Expected behavior
I’m expecting the function invocation to gracefully terminate at the end of the execution of the logic in the app
.
Actual behavior
All logic executed, then the function waits until the timeout.
Additional context
I’m using serverless-mysql
as my DB client.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@disbelief That’s a good idea. Would you mind contributing by filing an issue describing what kind of problems you are facing when you’re creating your own adapter? It would be great if we can ensure the documentation are covering all those problems.
@disbelief No worries!
That’s right, you should set it in the adapter. I can’t see your code for myAdapter, but the second argument of an adapter would be
LaconiaContext
, which would containcontext
as well, just like how you have done it in the app.