Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): webhook max retry #2541

Merged
merged 38 commits into from
Mar 19, 2024
Merged

feat(backend): webhook max retry #2541

merged 38 commits into from
Mar 19, 2024

Conversation

sabineschaller
Copy link
Member

Changes proposed in this pull request

  • adds env variable for webhook max retries
  • checks whether number of attempts < webhookMaxRetry before sending event

Context

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Documentation added
  • Make sure that all checks pass
  • Bruno collection updated

@github-actions github-actions bot added type: tests Testing related pkg: backend Changes in the backend package. type: source Changes business logic pkg: documentation Changes in the documentation package. type: documentation Improvements or additions to documentation labels Mar 14, 2024
Copy link

netlify bot commented Mar 14, 2024

Deploy Preview for brilliant-pasca-3e80ec ready!

Name Link
🔨 Latest commit e94fdb1
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/65f9a64dd046b900087bba44
😎 Deploy Preview https://deploy-preview-2541--brilliant-pasca-3e80ec.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -375,5 +387,13 @@ describe('Webhook Service', (): void => {
event.createdAt.getTime() + RETRY_BACKOFF_MS
)
})

test('Does not send event if webhookMaxAttempts is reached', async (): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we assert using nock that the webhook was not fired here? just as a sanity (in addition to asserting that processNext() returns undefined).

@@ -375,5 +387,13 @@ describe('Webhook Service', (): void => {
event.createdAt.getTime() + RETRY_BACKOFF_MS
)
})

test('Does not send event if webhookMaxAttempts is reached', async (): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also use withConfigOverride function to make sure we never have to change this test in case the default config number changes.

Co-authored-by: Max Kurapov <max@interledger.org>
sabineschaller and others added 14 commits March 19, 2024 15:04
…axCost (#2537)

* chore: add graphql depth restriction

* feat: properly enable graphql armor

* style: remove unnecessary space

* chore: add armor to auth admin server
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
#2549)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
beniaminmunteanu and others added 8 commits March 19, 2024 15:24
* feat(telemetry): LIVENET now points to new livenet NLB

* Update packages/backend/src/config/app.ts

Co-authored-by: Max Kurapov <max@interledger.org>

* Update packages/backend/src/config/app.ts

Co-authored-by: Max Kurapov <max@interledger.org>

---------

Co-authored-by: Max Kurapov <max@interledger.org>
Co-authored-by: Sabine Schaller <sabine@interledger.org>
* feat(auth): improve GNAP error responses

* fix: add extra arg to ctx.throw

* feat: middleware error improvements

* feat: add error messages to grant details endpoint

* fix: update error messages in grant routes

* feat: create utility function to generate GNAP errors, create enum for GNAP error codes

* feat: helper function throws instead of generates response
* feat: setup basic test env

* feat: seed integration environment

- cmd to start integration environment and run tests
- seeds environment on test run
- extracts common MASE functionality into new mock-account-servicing-lib

* refactor(localenv,integration): move graphql url to config from seed

- moves graphql url to config from seed
- also removes self section which only contained unused properties

* refactor: move testenv configuration into new dir

* refactor: cleanup env vars

* feat: add webhook server, fix env vars

* chore: comment

* feat: start grant request test

* fix: eslint errors

* fix: docker compose env vars

* feat: add --build arg

* fix: incoming-payment grant initiation request

Grant request was failing with invalid signature. This was fixed by directing hte backend to use the same private key being used to create the open payments client.

* fix: ts error

* feat: implement tests through Create Quote

* chore: upgrade op client

* feat: partially implemented grant request outgoing payment test

* feat: rework to host.docker.internal

- switches hostname to host.docker.internal to resolve url mismatch problem
- finishes grant request outgoing payment test
- cleans up some configuration and test variables

* feat: add p2p flow test

* feat: add continuation step with consent mocking

* fix: rm obsolete type cast to any and comment

* feat: add create ougoing payment test

* fix: bad pnpm-lock merge

* feat: build deps in mock ase job

* feat: get non existant wallet address test

* fix: update open payments pkg

* chore: fix lint warnings

* feat: implement continuation polling

* chore: test cleanup

* refactor: generate gql in tests instead of import from lib

* chore: rm old comment

* chore: use latest http-singature-utils to match other deps

* chore: pnpm i

* chore: use latest koa-bodyparser

* chore: rm engine strict

* chore: revert rm engine strict

- fixes netlify ci failure but ultimately not the correct fix

* chore(integration): dont ignore env, rm example env

* refactor: use docker healthcheck for running tests

* chore: move healthcheck to last started docker container

* feat: use latest open payments pkg, no body requird on continuation

* chore: pnpm i, fix broken lockfile (no apollo version)

* refactor: move webhook event enum to types

* refactor: move run integration script to test/integration

* Update packages/mock-account-servicing-lib/package.json

Co-authored-by: Sabine Schaller <sabine@interledger.org>

* refactor: simplify mock-account-servicing-entity ci step

* feat(integration): exit run-tests early if containers fail to start

* feat: use pino logger

* refactor: rename mock account servicing lib

* refactor: rename class files to camel case

* fix: import correct body parser

* refactor: poll instead of delay

* refactor: simplify call to poll condition only

* fix: update filenames

* refactor: change filename name to kebab case

---------

Co-authored-by: Sabine Schaller <sabine@interledger.org>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* feat: flag to enable/disable SPSP

* test: update to cover all cases

* docs: add link to glossary
@github-actions github-actions bot added type: ci Changes to the CI pkg: frontend Changes in the frontend package. pkg: auth Changes in the GNAP auth package. type: localenv Local playground pkg: mock-ase labels Mar 19, 2024
@@ -389,11 +390,18 @@ describe('Webhook Service', (): void => {
})

test('Does not send event if webhookMaxAttempts is reached', async (): Promise<void> => {
const scope = nock(webhookUrl.origin)
await event.$query(knex).patch({
attempts: 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe now attempts: Config.webhookMaxRetry is better

Comment on lines 399 to 403
expect(
nock.emitter.on('no match', (_req) => {
return true
})
).toBeTruthy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be truthy since nock.emitter.on just returns an EventEmitter. Also, I think this event listener would have to be defined before we make any requests for this to work.

Maybe instead of doing this, we could just piggyback off of nock(webhookUrl.origin) as such:

      let requests = 0
      const scope = nock(webhookUrl.origin)
        .post('/')
        .reply(200, () => {
          requests++
        })
      expect(requests).toBe(0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what happens when you try to finish things quickly...

@github-actions github-actions bot removed type: ci Changes to the CI pkg: frontend Changes in the frontend package. pkg: auth Changes in the GNAP auth package. type: localenv Local playground pkg: mock-ase labels Mar 19, 2024
@sabineschaller sabineschaller merged commit b124abd into main Mar 19, 2024
22 checks passed
@sabineschaller sabineschaller deleted the s2-webhook-retry branch March 19, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: backend Changes in the backend package. pkg: documentation Changes in the documentation package. type: documentation Improvements or additions to documentation type: source Changes business logic type: tests Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set the maximum webhook retries
5 participants