I’m getting a strange error all of a sudden: ```b4...
# help
s
I’m getting a strange error all of a sudden:
Copy code
b4fe69cd-99e0-46bc-9c22-dafcaa3f7907 REQUEST dev-microservices-core-cognitoEmailSender [lambda/auth/cognito-email-sender.main] invoked
Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'buildClient' of undefined","reason":"TypeError: Cannot read property 'buildClient' of undefined","promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'buildClient' of undefined","    at process.<anonymous> (file:///Volumes/SuperData/Sites/reelcrafter/v2-microservices/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)","    at process.emit (events.js:400:28)","    at process.emit (domain.js:475:12)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
it’s only one function, for some odd reason
there’s nothing odd about the way it’s defined as far as I can tell 🤔
here’s the debug log right before the error:
Copy code
[2022-01-23T19:41:13.263] [DEBUG] client - Invoking local function...
[2022-01-23T19:41:13.267] [DEBUG] client - Triggering {
  id: '06a52ecc',
  handler: 'lambda/auth/cognito-email-sender.main',
  runtime: 'nodejs14.x',
  srcPath: 'src',
  bundle: {
    externalModules: [ 'sharp', 'knex', '@aws-sdk/signature-v4-crt' ],
    loader: { '.node': 'binary' },
    esbuildConfig: { plugins: 'config/esbuild.js' }
  },
  root: '/Volumes/SuperData/Sites/reelcrafter/v2-microservices'
}
[2022-01-23T19:41:13.268] [DEBUG] client - Spawning {
  command: 'npx',
  args: [
    'aws-lambda-ric',
    '/Volumes/SuperData/Sites/reelcrafter/v2-microservices/.sst/artifacts/06a52ecc/src/lambda/auth/cognito-email-sender.main'
  ],
  env: { AWS_LAMBDA_NODEJS_USE_ALTERNATIVE_CLIENT_1: 'true' }
}
same error if I invoke the Lambda function directly
as expected, after setting
enableLiveDev: false
, the function works fine
f
Lemme pull in Dax. @thdxr here’s the formatted stack trace. I wasn’t able to fine
buildClient
in the lambda-ric repo, could it be come from @Sam Hulick’s Lambda code?
Copy code
{
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "TypeError: Cannot read property 'buildClient' of undefined",
  "reason": "TypeError: Cannot read property 'buildClient' of undefined",
  "promise": {},
  "stack": [
    "Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'buildClient' of undefined",
    "    at process.<anonymous> (file:///Volumes/SuperData/Sites/reelcrafter/v2-microservices/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)",
    "    at process.emit (events.js:400:28)",
    "    at process.emit (domain.js:475:12)",
    "    at processPromiseRejections (internal/process/promises.js:245:33)",
    "    at processTicksAndRejections (internal/process/task_queues.js:96:32)"
  ]
}
t
Yeah it's not coming from our code it's coming from the application code
s
strange. but it only fails when
enableLiveDev
is enabled
ah:
Copy code
import b64 from 'base64-js';
import encryptionSdk from '@aws-crypto/client-node';
import { sendEmail } from '~/libs/email';

const { decrypt } = encryptionSdk.buildClient(
  encryptionSdk.CommitmentPolicy.REQUIRE_ENCRYPT_ALLOW_DECRYPT
);
that stack trace was misleading!
I wonder if there’s something weird about the
@aws-crypto
package where it doesn’t export modules properly when using
sst start
t
hm it's weird that it works when liveDev is disabled though
s
yeah. not 100% surprising though.. AWS X-Ray totally fails in live dev mode too. but I think that’s because it connects to a daemon of some sort
the strange part is, this used to work in live dev mode before. at some point in time
I can do some more digging later. like, import from the module and see what it returns
f
Hey @Sam Hulick, just checking in and see if you are still having this issue?
s
@Frank hey! I can check in a little bit and let you know. I’ve left
enableLiveDev
disabled on that function since the problem arose
f
Thanks @Sam Hulick, whenever u get a chance.