snowplow / snowplow/snowplow-javascript-tracker

Retry is disabled by default for `POST` method

Open
#1,290 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:defect
Dominant language
TypeScript
Stars
590
Forks
232
Avg merge
2h 22m
Merged PRs (30d)
3

Description

Describe the bug
Retries are disabled by default for the POST method. We used a config similar to the one below, intending to have 3 retries:

gotEmitter(
  process.env.SNOWPLOW_ENDPOINT, // endpoint
  'https',
  undefined, // port
  'post', // method
  1, // buffer size
  3, // retries
);

However, Snowplow events were not retried on failure due to the Got defaults:

By default, Got does not retry on POST.

To Reproduce
Configure Snowplow with 'post' method and retries >= 1.

Expected behavior
If Snowplow is configured with a positive number of retries, then emit should be retried on network error.

Suggested solution
By default, enable retries for GET and POST methods in gotEmitter.

If the retry argument is a number (instead of an object), then the following object is passed to Got:

const retries: Partial<RequiredRetryOptions> = {
  limit: retry,
  methods: ['GET', 'POST'],
};

Otherwise, if the retry.methods is undefined it should default to be enabled for both methods used by Snowplow:

const retries: Partial<RequiredRetryOptions> = {
  methods: ['GET', 'POST'],
  ...retry,
};

Desktop (please complete the following information):

  • OS: Linux
  • Node: v20.11.0

Additional context
@snowplow/node-tracker version 3.19.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with trackers/node-tracker/src/got_emitter.ts and reproduce the configuration using the POST method with retries set to 3. Verify that network failures retry for POST, while an explicitly supplied retry.methods configuration remains respected; done means the reported configuration retries as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.