aws-mobile-appsync-sdk-js icon indicating copy to clipboard operation
aws-mobile-appsync-sdk-js copied to clipboard

Subscription WebSocket establishment timeout errors cause TypeErrors instead of being properly logged and handled

Open tbartley opened this issue 4 years ago • 0 comments

Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the official AWS AppSync forum

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When attempts to establish the web socket for a subscription fail a TypeError results rather than the actual error being reported because the error object is not able to be JSON.stringify'ed in the log message of this code:

          this.awsRealTimeSocket.onerror = (error) => {
            logger(`WebSocket closed ${JSON.stringify(error)}`);
          };

for example:

    TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'Timeout'
        |     property '_idlePrev' -> object with constructor 'TimersList'
        --- property '_idleNext' closes the circle
        at JSON.stringify (<anonymous>)
      at WebSocket._this.awsRealTimeSocket.onerror (node_modules/aws-appsync-subscription-link/lib/realtime-subscription-handshake-link.js:563:75)
      at WebSocket.onError (node_modules/ws/lib/EventTarget.js:109:16)
      at WebSocket.finalize (node_modules/ws/lib/WebSocket.js:182:41)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Reproduces on connection timeout.

What is the expected behavior?

These errors are handled more gracefully.

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?

4.0.3, nodejs.

tbartley avatar Apr 18 '21 20:04 tbartley