<@U01JVDKASAC> I think I might’ve spotted a bug in...
# help
j
@Frank I think I might’ve spotted a bug in the handler definition using a python function. Here’s my code:
Copy code
const api = new sst.Api(this, "Api", {
      routes: {
        "POST /": {
          function: {
            srcPath: "src",
            handler: "people_data_enrichment/handlers/sns_publisher.handler",
            runtime: "python3.8",
            environment: {
              USER_EVENTS_TOPIC_ARN: topic.topicArn,
            },
            permissions: [topic],
          },
        },
      },
    });
however, in AWS the handler is defined simply as
sns_publisher.handler
. If I change the handler to
people_data_enrichment.handlers.sns_publisher.handler
then I get the normal behavior again. Otherwise, I get a
Unable to import module 'sns_publisher'
f
Oh i see. Does your file structure look like this?
Copy code
/
  people_data_enrichment/
    handlers/
      sns_publisher.py
j
yes 👍
this will work just fine for development, but breaks when deployed though
f
I see.. let me give that a try.
j
ok! Thanks again, Frank 🙏
f
Hey @José Ribeiro, I just pushed out v0.24.0 with the fix.
Give it a try and let me know if it works for you!
j
works as a charm 🙏 thank you @Frank!
interestingly I’m getting :
Copy code
"TypeError [ERR_INVALID_URL]: Invalid URL: undefined",
in one of the lambdas when using the app
sst start
. I’ll try redeploying the stack, but just wanted to let you know in case it could be sth related
Copy code
2021-06-02T15:14:22.500Z ca8f0424-605b-5361-bd41-5d15c2dd1b32 INFO connectAndSendMessage()
2021-06-02T15:14:22.500Z	ca8f0424-605b-5361-bd41-5d15c2dd1b32	ERROR	Invoke Error 	
{
    "errorType": "TypeError",
    "errorMessage": "Invalid URL: undefined",
    "code": "ERR_INVALID_URL",
    "input": "undefined",
    "stack": [
        "TypeError [ERR_INVALID_URL]: Invalid URL: undefined",
        "    at onParseError (internal/url.js:258:9)",
        "    at new URL (internal/url.js:334:5)",
        "    at initAsClient (/var/task/node_modules/ws/lib/websocket.js:502:17)",
        "    at new WebSocket (/var/task/node_modules/ws/lib/websocket.js:71:7)",
        "    at connectAndSendMessage (/var/task/index.js:55:15)",
        "    at Runtime.exports.main [as handler] (/var/task/index.js:41:5)",
        "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
    ]
}
f
hmm… did it work after redeploy?
j
sorry, didn’t follow up — yes, worked just as fine 🙏
f
Hmm.. it seems the Lambda didn’t know what websocket URL to send the request to.. if it happens again, can you check in ur AWS Lambda console and see if the Lambda getting invoked has
SST_DEBUG_ENDPOINT
environment variable set?
j
sure, will do it! thinking back, I assume this might be related to some tweaking of the prod function variables I was doing while starting sst.