sst / sst

Build full-stack apps on your own infrastructure.
https://sst.dev
MIT License
24.05k stars 1.85k forks source link

appsync.connection subscribe_error #5901

Closed yotambarzilay closed 3 weeks ago

yotambarzilay commented 3 weeks ago

Hello,

I'm trying sst for the first time. I created a simple lambda function that logs and returns the event it receives. When I run npx sst dev --stage local and try to trigger the function, it seems from the logs that the appsync connection fails (msg service=appsync.connection type=subscribe_error id=0197773bb3591e88543bdc7d), and the local function is never triggered.

With sst deploy the function does work. I'm at a loss, hoping someone can help me troubleshoot this.

sst.config.ts:

/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
  app(input) {
    console.log('input', input);
    return {
      name: 'my-app',
      removal: input?.stage === 'production' ? 'retain' : 'remove',
      protect: ['production'].includes(input?.stage),
      home: 'aws',
    };
  },
  async run() {
    const playground = new sst.aws.Function('MyFunction', {
      handler: 'playground/index.handler',
      runtime: 'nodejs22.x',
      timeout: '1 minute',
      memory: '1024 MB',
    });

    return {
      playground: playground.arn,
    };
  },
});

playground/index.js:

export const handler = async (event) => {
  console.log(`playground triggered:`, event);

  return {
    message: 'playground triggered',
    event,
  };
};

Lambda function CloudWatch Log:

2025/06/16 05:34:50 INFO waiting for interrupt signal
2025/06/16 05:34:50 INFO connecting service=appsync.connection
2025/06/16 05:34:50 INFO connect message service=appsync.connection msg="map[connectionTimeoutMs:300000 type:connection_ack]"
2025/06/16 05:34:50 INFO subscribing to prefix=/sst/my-app/local/035b62550359445a826689b0e2f1feef/in
2025/06/16 05:34:50 INFO msg service=appsync.connection type=ka id=<nil>
2025/06/16 05:34:50 INFO msg service=appsync.connection type=subscribe_error id=0197773bb3591e88543bdc7d
START RequestId: be3xxxxx-xxxx-xxxx-xxxx-xxxxxxxcdb90 Version: $LATEST
status 200 OK
2025/06/16 05:34:53 ERROR failed to close message requestID=be3xxxxx-xxxx-xxxx-xxxx-xxxxxxxcdb90 error="request failed with status 401: {\n  \"errors\" : [ {\n    \"errorType\" : \"UnauthorizedException\"\n  } ]\n}"
status 200 OK
2025/06/16 05:34:53 ERROR failed to close message requestID=be3xxxxx-xxxx-xxxx-xxxx-xxxxxxxcdb90 error="request failed with status 401: {\n  \"errors\" : [ {\n    \"errorType\" : \"UnauthorizedException\"\n  } ]\n}"
status 200 OK
2025/06/16 05:34:53 ERROR failed to close message requestID=be3xxxxx-xxxx-xxxx-xxxx-xxxxxxxcdb90 error="request failed with status 401: {\n  \"errors\" : [ {\n    \"errorType\" : \"UnauthorizedException\"\n  } ]\n}"

The "failed to close message" is then repeated multiple times every second

Appreciate any help 🙏🏻

macOS 15.5 M1 Max
node v22.15.1
sst 3.17.5
yotambarzilay commented 3 weeks ago

I ended up deleting the sst AppSync api from aws, then ran sst dev again and now it works. 🤷‍♂