Emil Styrke
02/22/2022, 10:24 AM{
"data": {
"events": null
},
"errors": [
{
"path": [
"events"
],
"data": null,
"errorType": "Runtime.UnhandledPromiseRejection",
"errorInfo": null,
"locations": [
{
"line": 28,
"column": 3,
"sourceName": null
}
],
"message": "TypeError: Cannot read property 'join' of undefined"
}
]
}
Is this expected?Emil Styrke
02/22/2022, 10:25 AMNoah D
02/22/2022, 10:31 AMjoin
on. My suspicion is that it will be on an object which can be undefined if the circumstance isn't correct, and youll need to handle situations where it is undefined. For example my lambdas request.requestContext.authorizer
can be undefined so I have to make sure it exists by doing something like the following when i get userIds
to ensure it is defined before using it elsewhere
export const getUserId = (event: EndpointEvent): string => {
if (!event.requestContext.authorizer || !event.requestContext.authorizer.iam) {
throw new Error('Not authorized');
}
const userId = event.requestContext.authorizer.iam.cognitoIdentity.identityId;
if (!userId) {
throw new Error('Not Authorized');
}
return userId;
};
Frank
Frank
sst deploy
the errorous Lambda code?Emil Styrke
02/23/2022, 7:18 PMEmil Styrke
02/23/2022, 7:25 PM// handle response error
if (responseError) {
// Note: Do not throw. If error is thrown, errorType becomes
// "Runtime.UnhandledPromiseRejection". We need to preserve the
// original error type.
const e = new Error();
e.name = responseError.errorType;
e.message = responseError.errorMessage;
e.stack = responseError.stackTrace.join("\n");
_ref.callback(e);
}
The line number doesn´t match the error, but I bet that responseError.stackTrace is undefined.Emil Styrke
02/23/2022, 7:37 PM{"responseError":{"errorMessage":"\'user_id\'","errorType":"KeyError"}}
So indeed no stackTrace
key there.Frank
Emil Styrke
02/23/2022, 8:14 PMFrank
Emil Styrke
02/23/2022, 8:15 PMFrank
Emil Styrke
02/23/2022, 8:37 PM"errors": [
{
"path": [
"events",
3,
"participants",
0,
"participant"
],
"data": null,
"errorType": "KeyError",
"errorInfo": null,
"locations": [
{
"line": 37,
"column": 7,
"sourceName": null
}
],
"message": "'user_id'"
}
Emil Styrke
02/23/2022, 8:38 PMFrank
Frank
Emil Styrke
02/24/2022, 9:14 AM{
"data": {
"events": null
},
"errors": [
{
"path": [
"events"
],
"data": null,
"errorType": "OperationalError",
"errorInfo": null,
"locations": [
{
"line": 28,
"column": 3,
"sourceName": null
}
],
"message": "(2003, \"Can't connect to MySQL server on '[host]' (timed out)\")"
}
]
}
Frank
Emil Styrke
03/16/2022, 9:00 AMFrank