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

Problems encountered in the custom webhook node #10778

Closed
ybom77 opened this issue Sep 12, 2024 · 6 comments
Closed

Problems encountered in the custom webhook node #10778

ybom77 opened this issue Sep 12, 2024 · 6 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@ybom77
Copy link

ybom77 commented Sep 12, 2024

Bug Description

When I customize a webhook node, the webhook address is accessible and returns the correct results when I first test and activate the node. However, after refreshing the node, the webhook address changes. When I test with the new address, the node returns results correctly, but upon activating the node, the webhook address returns a 404 error. If I access the original address used during initialization, the node returns results correctly.

To Reproduce

  1. Customize a webhook node and add it to the UI.
    image

  2. Set the node's URL address.

  3. Test and activate the node, and it returns the expected results correctly.
    image
    image

  4. Refresh the workflow.
    image

  5. Retest the node, and it returns results correctly.
    image

  6. When reactivating the node, it returns a 404 error.
    image

  7. Accessing the URL generated in step 3 returns results correctly.
    image

Expected behavior

  1. After the URL changes, accessing the new URL still executes correctly. This allows me to copy the URL at any time. Otherwise, if the URL changes when refreshing the node, I won't be able to find the original request URL.

  2. The URL should remain unchanged while the node is activated, and it must not be altered. It should always be the value set during activation.

Operating System

22.04

n8n Version

1.55.0

Node.js Version

20

Database

SQLite (default)

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Sep 12, 2024

Hey @ybom77,

We have created an internal ticket to look into this which we will be tracking as "GHC-225"

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Sep 12, 2024
@Joffcom
Copy link
Member

Joffcom commented Sep 12, 2024

Hey @ybom77

Quickly looking at this it is likely to be an issue with the code being used in the custom node rather than an issue with n8n itself.

The form trigger node I created which is based on the webhook node appears to be working correctly still.

Can you share a link to your node so we can take a look?

@ybom77
Copy link
Author

ybom77 commented Sep 12, 2024

@Joffcom Thanks for your reply, this is my node

import type {INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData} from "n8n-workflow";

export class AppWebhookTrigger implements INodeType {
	description: INodeTypeDescription = {
		defaults: {
			name: 'app webhook'
		},
		displayName: 'app webhook Trigger',
		description: 'app webhook',
		name: 'weixinMpTrigger',
		inputs: [],
		outputs: ['main'],
		group: ['trigger'],
		version: 1,
		properties: [
			{
				displayName: 'Event',
				name: 'event',
				type: 'options',
				noDataExpression: true,
				options: [{
					displayName: "path1",
					name: 'Path1',
					value: "text"
				}, {
					displayName: "path2",
					name: "Path2",
					value: "image"
				}, {
					displayName: "path3",
					name: "Path3",
					value: "voice"
				}],
				default: 'text'
			}
		],
		webhooks: [
			{
				name: 'default',
				httpMethod: 'POST',
				responseMode: 'onReceived',
				path: '={{$parameter["event"]',
			}
		]
	}

	async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
		const requestBody = this.getRequestObject().body || {}
		return {
			workflowData: [
				[
					{
						json: requestBody
					}
				]
			],
			webhookResponse: "success"
		}
	}
}


@Joffcom
Copy link
Member

Joffcom commented Sep 13, 2024

Hey @ybom77,

The bit that changes is the ID assigned, Depending on the changes you make to the node or the workflow this may change but it should also register. I am not sure why it is not loading the displayed value, When you reactivate your node how are you doing that?

Does this also happen with any of our shipped webhook based nodes or only your own as this will change if this is an issue to be handled here as an n8n bug or on the support forum as a third party integration bug.

@ybom77
Copy link
Author

ybom77 commented Sep 13, 2024

Thinks @Joffcom

In n8n, the default webhook node usually retains the same URL after a refresh. However, this issue only occurs with the webhook nodes I create.

I think this is a bug, as the webhook URL changes each time I refresh the node. If I forget this URL, I won't be able to find the correct URL later, as the address changes every time the workflow is refreshed, regardless of whether the workflow is currently active.

@Joffcom
Copy link
Member

Joffcom commented Sep 16, 2024

Hey @ybom77,

It does sound like a bug but if it doesn't happen with the nodes we ship it sounds like it is going to be a bug with your node, I have done a few tests looking at other community nodes that use webhooks and they are all working as expected. Have you tried publishing your node and seeing if it has the same issue when installed as a community node instead of being linked?

@ybom77 ybom77 closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

2 participants