Need help, I learn the n8n docs “Build your first workflow”, delete unscription email message form gmail

Hello All

I am new to n8n, spend many days reading n8n docs and get more, but do need help now.

Thanks in adveave if someone help me.

the error message below

{“message”:“socket hang up”,“name”:“Error”,“stack”:“Error: socket hang up\n at connResetException (internal/errors.js:607:14)\n at TLSSocket.socketOnEnd (_http_client.js:493:23)\n at TLSSocket.emit (events.js:327:22)\n at endReadableNT (internal/streams/readable.js:1327:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)”,“code”:“ECONNRESET”}

Please share the workflow

(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

{
  "nodes": [
    {
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "position": [
        240,
        300
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        460,
        300
      ],
      "parameters": {
        "resource": "message",
        "operation": "getAll",
        "returnAll": true,
        "additionalFields": {
          "q": "-in:chats unsubscribe",
          "format": "ids"
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "1",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1
    },
    {
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        680,
        300
      ],
      "parameters": {
        "options": {},
        "batchSize": 100
      },
      "typeVersion": 1
    },
    {
      "name": "Gmail1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        880,
        300
      ],
      "parameters": {
        "resource": "message",
        "messageId": "={{$json[\"id\"]}}",
        "operation": "delete"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "1",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Gmail": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Share the output returned by the last node

NodeApiError: UNKNOWN ERROR - check the detailed error for more information
    at Object.googleApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Gmail/GenericFunctions.js:47:15)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Gmail/Gmail.node.js:415:40)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:447:47

Thanks again

Information on your n8n setup

  • n8n version:
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:

Hey @makechinafreedom,

Welcome to the community :tada:

I am sorry that you ran into this error. Can you share the workflow you created? It will help me to recreate the issue. Please remove any sensitive data (eg. your email address).

Thanks, harshil1712

You know I’m a newbie, I don’t even know how to share with you, wow, I will take a look how to share? you can tell me how to share with you,

I followed the official example, Quickstart | Docs [Build your first workflow]

I guess there is an error in this step. The original text is: Message ID: Use the gears button to enter an expression. This enables the ID of each message from the first Gmail node to be dynamically passed to this node. From the Edit Expression window, use the menu to find and select the message ID in the Output Data:

The Expression I wirte it same like on the pic, but the pictuere shows the [not found] and mine shows the message id.

Thanks again , please tell me how to share with you…

I followed the steps mentioned in the docs, and I couldn’t replicate the error. The workflow ran as expected.

You can learn how to share the workflows here: How can I contribute? | Docs

Thanks,

I’ll learn it .

1 Like

share it now, check out if u get it or not…

Thank you! I’ve edited the topic to add the workflow and have deleted it from the workflow repository.

I ran your workflow too, and it returned the expected out. I couldn’t replicate the issue. Researching on the internet it seems like this is due to the slow response coming from Gmail. I am assigning this to @MutedJam, he might be able to help better.

If you’re learning n8n, I suggest you take the beginner course. It covers the basics and in the end, you can earn a certificate too! You can take the course here: Introduction | Docs

1 Like

ok , I see , Thanks a lot .

1 Like

@ harshil1712

I executed it again just now, and it seems to be a little better but still not works…

Well, I won’t be able to help with slow responses from Gmail’s API.

But as a next step you could try:

  • Using smaller batches
  • Adding a wait time between each batch to avoid overloading the Gmail API
  • Enable the retry setting with a wait time between each attempt:

Might be worth adding that Gmail only allows 25 deletions per second as per Usage limits  |  Gmail API  |  Google Developers, seeing your screenshot shows a lot more items you probably want to adjust batch size and wait time to stay below that threshold. The node seems to delete individual messages rather then performing a batch delete (which would be a cool feature request going forward).

@MutedJam
Thanks I will try to set 10…
as you know china’s CCP block google,twitter and facebook and more, I use VPN to get online that is the reason … anyway, thanks a lot.
it seems works , see the pic below


2783 items to 2505 items,

1 Like

Thanks a lot, fingers crossed this works out! To add a wait time, you can use our Wait node.

I’ve also added a note to our internal list of product improvements to implement the batch delete operation.

This would mean that instead of making one request for each Gmail message to delete, n8n would only need to make one request for a large number of messages, meaning the entire operation would be a lot more likely to succeed in difficult network conditions (as only one request would need to make it through instead of thousands of requests).

You might also want to raise this as a regular feature request here on our forum, so other users can vote for it (and thus help us decide on development efforts).

@MutedJam following ur instruction, it works now… Thanks…

1 Like