Skip to content

paginateGetLogEvents should guarantee sane behavior or throw an error explaining how to call it #6631

@jedwards1211

Description

@jedwards1211

Checkboxes for prior research

Describe the bug

Right now, we have to manually set startFromHead: true when calling paginateGetLogEvents, or the pagination ends unexpectedly.

#5559 (comment)

This kind of thing is a really irritating waste of time, it should be improved. paginateGetLogEvents should set whatever default options necessary to ensure sane behavior or throw an error explaining how to call it in a way that actually works

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/client-cloudwatch-logs@3.651.1

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

Node 20.10.0

Reproduction Steps

    for await (const page of paginateGetLogEvents(
      {
        client,
        stopOnSameToken: true,
      },
      {
        logGroupIdentifier: logGroupName.replace(/:\*$/, ""),
        logStreamName,
        startTime: startTime.getTime(),
        endTime: endTime.getTime(),
      },
    )) {

Observed Behavior

the loop ends after getting one page

Expected Behavior

the loop goes through all pages between startTime and endTime

Possible Solution

If the underlying service can't be improved then paginateGetLogEvents should set a default value of startFromHead: true when none is provided, so that it can behave in a sane manner. If paginating backward from most to least recent with startFromHead: false/no value can't work, then paginateGetLogEvents should just throw an error explaining it that option doesn't work.

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions