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

refactor(core): Fix push message type inference #12331

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Dec 20, 2024

This PR adjusts the Push.send argument so that TypeScript is able to narrow down payloads based on push types.

Capture 2024-12-20 at 14 54 08@2x

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Dec 20, 2024
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ckages/cli/src/workflow-execute-additional-data.ts 0.00% 4 Missing ⚠️
packages/cli/src/push/index.ts 0.00% 1 Missing ⚠️
packages/cli/src/webhooks/test-webhooks.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Member

@netroy netroy left a comment

Choose a reason for hiding this comment

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

besides the comment in PubSubHandler, LGTM

packages/cli/src/push/index.ts Outdated Show resolved Hide resolved
@@ -156,7 +157,7 @@ export class PubSubHandler {
'relay-execution-lifecycle-event': async ({ type, args, pushRef }) => {
if (!this.push.getBackend().hasPushRef(pushRef)) return;

this.push.send(type, args, pushRef);
this.push.send({ type, data: args } as PushMessage, pushRef);
Copy link
Member

Choose a reason for hiding this comment

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

instead of casting as PushMessage here, maybe we could update the types for this event in packages/cli/src/events/maps/pub-sub.event-map.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ended up removing all generics from push as well: 75b9e71

@ivov ivov requested a review from netroy December 20, 2024 17:03
Copy link

cypress bot commented Dec 20, 2024

n8n    Run #8453

Run Properties:  status check passed Passed #8453  •  git commit fe7fb41ad8: 🌳 master 🖥️ browsers:node18.12.0-chrome107 🤖 PR User 🗃️ e2e/*
Project n8n
Branch Review master
Run status status check passed Passed #8453
Run duration 04m 54s
Commit git commit fe7fb41ad8: 🌳 master 🖥️ browsers:node18.12.0-chrome107 🤖 PR User 🗃️ e2e/*
Committer Iván Ovejero
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 483
View all changes introduced in this branch ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit fe7fb41 into master Dec 20, 2024
37 checks passed
@ivov ivov deleted the fix-push-message-type-inference branch December 20, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants