question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWSCloudWatchProvider fails to log to a brand-new log stream

See original GitHub issue

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Not applicable

Amplify Categories

Not applicable

Environment information

Put output below this line

System: OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa) CPU: (12) x64 Intel® Core™ i7-10750H CPU @ 2.60GHz Memory: 9.66 GB / 12.33 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.17.5 - /usr/bin/node Yarn: 1.22.11 - /mnt/c/Users/iblis/AppData/Roaming/npm/yarn npm: 6.14.14 - /usr/bin/npm npmGlobalPackages: aws-cdk: 1.122.0 npm: 6.14.14

Describe the bug

AWSCloudWatchProvider (packages/core/src/Providers/AWSCloudWatchProvider.ts) throws the following errors when sending logs to a brand new stream.

API Response

{"__type":"InvalidParameterException","message":"1 validation error detected: Value '' at 'sequenceToken' failed to satisfy constraint: Member must have length greater than or equal to 1"}

When I call the CloudWatch API directly without a token to initialize the first stream message, the provider works.

Expected behavior

AWSCloudWatchProvider shouldn’t be initializing _nextSequenceToken to empty string. The value should be undefined.

Original Line: 379 this._nextSequenceToken = logStream.uploadSequenceToken || '';

Requested Changes: this._nextSequenceToken = logStream.uploadSequenceToken || undefined;

Reproduction steps

  1. Create a new aws-amplify logger
  2. Add Pluggable: AWSCloudWatchProvider with a non-existing stream name
  3. Attempt to log an entry

Code Snippet

const logger = new Logger('test', 'DEBUG);
logger.addPluggable(
    new AWSCloudWatchProvider({
      logGroupName: `/app/dev`,
      logStreamName: 'brand-new-stream',
      region: 'us-east-2`,
    })
  );

logger.debug('hello');

Log output

**API Response** ``` {"__type":"InvalidParameterException","message":"1 validation error detected: Value '' at 'sequenceToken' failed to satisfy constraint: Member must have length greater than or equal to 1"} ```

Log Output

31:07.130 AWSCloudWatch - failure during log push: InvalidParameterException: 1 validation error detected: Value '' at 'sequenceToken' failed to satisfy constraint: Member must have length greater than or equal to 1

31:07.130 AWSCloudWatch - error during _safeUploadLogEvents: TypeError: Cannot read properties of undefined (reading 'nextSequenceToken')

[ERROR] 31:07.130 AWSCloudWatch - error when calling _safeUploadLogEvents in the timer interval - TypeError: Cannot read properties of undefined (reading 'nextSequenceToken')

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ashika01commented, Nov 22, 2021

I have merged in #9181. Thank you @aaronlna. It is now in aws-amplify@unstable and should be released in @latest thursday during our weekly release cycle. Could you verify by upgrading to unstable and let us know if there are any issues?

0reactions
github-actions[bot]commented, Dec 9, 2022

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot pushing log data to CloudWatch - Amazon AWS
I'm unable to push log data to Amazon CloudWatch Logs using the CloudWatch Logs agent (awslogs). How do I troubleshoot this?
Read more >
Working with log groups and log streams - AWS Documentation
Explains how to create and tag log groups, encrypt log data using AWS KMS, and change log retention in CloudWatch Logs.
Read more >
Why isn't the unified CloudWatch agent pushing log events?
I'm using the unified CloudWatch agent to push logs to Amazon CloudWatch Logs. However, I can't see the logs in the CloudWatch Logs...
Read more >
Fix "Log group does not exist" for Lambda logs in CloudWatch
When I try to view logs for my AWS Lambda function in the Amazon CloudWatch console, I get a "Log group does not...
Read more >
Resolve the slow log publishing error for CloudWatch Logs in ...
I want to resolve the error that I receive in AWS CloudFormation when I try to publish slow logs to Amazon CloudWatch Logs....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found