# preToolUse hook fails with ENAMETOOLONG for large files

**URL:** <https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346>\
**Category:** Bug Reports\
**Tags:** hooks, windows\
**Created:** [January 30, 2026, 3:02am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346 "2026-01-30T03:02:34Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_lonelywaitingliu](https://avatars.discourse-cdn.com/v4/letter/_/df788c/32.png) [@\_lonelywaitingliu](https://forum.cursor.com/u/_lonelywaitingliu)\
**Post date:** [January 30, 2026, 3:02am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/1 "2026-01-30T03:02:34Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

Issue: preToolUse hook fails with ENAMETOOLONG for large files

When editing large files, the hook receives the entire file content  
in tool\_input.content, causing spawn to fail before the script executes.

Suggested fix:

1. Write hook input to a temp file and pass the path instead
2. Or add config option to exclude tool\_input.content from hook payload
3. Or stream the data via stdin instead of passing in spawn args/env

### Steps to Reproduce

When editing large files, the hook receives the entire file content  
in tool\_input.content, causing spawn to fail before the script executes.

### Expected Behavior

no ENAMETOOLONG

### Operating System

Windows 10/11

### Version Information

Version: 2.4.23 (user setup)  
VSCode Version: 1.105.1  
Commit: 379934e04d2b3290cf7aefa14560f942e4212920  
Date: 2026-01-29T21:24:23.350Z  
Build Type: Stable  
Release Track: Early Access  
Electron: 39.2.7  
Chromium: 142.0.7444.235  
Node.js: 22.21.1  
V8: 14.2.231.21-electron.0  
OS: Windows\_NT x64 10.0.19045

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [January 30, 2026, 3:38pm UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/3 "2026-01-30T15:38:44Z")

</div>

Hey @_lonelywaitingliu!

Thanks for reporting this! Can you share the exact hook you’ve configured?

---

<div class="post-metadata">

**Author:** ![Matan\_OX](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Matan\_OX](https://forum.cursor.com/u/Matan_OX)\
**Post date:** [March 1, 2026, 7:28am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/5 "2026-03-01T07:28:55Z")

</div>

@Colin experiencing this as well, our hooks are node based so in the hooks.json we have:

```auto
"preToolUse": [
  {
    "command": "node <path_to_my_hook_file.js“,
    "type": "command"
  }
]

```

and the hook file itself has:

```auto
let inputData = '';

process.stdin.on('data', chunk => {
  inputData += chunk;
});

process.stdin.on('end', async () => {
 …hook logic
});

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [March 1, 2026, 11:03pm UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/6 "2026-03-01T23:03:36Z")

</div>

Thanks @Matan_OX! We’ve filed a bug for this.

---

<div class="post-metadata">

**Author:** ![weixiang](https://avatars.discourse-cdn.com/v4/letter/w/9fc348/32.png) [@weixiang](https://forum.cursor.com/u/weixiang)\
**Post date:** [March 4, 2026, 8:52am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/7 "2026-03-04T08:52:35Z")

</div>

When using cursor hooks on Windows platform, especially afterEdit hooks, when the input content is too large, it will cause error output to directly report execution error: spawn ENAMETOOLONG, resulting in the user’s callback program not executing and cannot take effectWhen using cursor hooks on Windows platform, especially afterEdit hooks, when the input content is too large, it will cause error output to directly report execution error: spawn ENAMETOOLONG, resulting in the user’s callback program not executing and cannot take effect

---

<div class="post-metadata">

**Author:** ![weixiang](https://avatars.discourse-cdn.com/v4/letter/w/9fc348/32.png) [@weixiang](https://forum.cursor.com/u/weixiang)\
**Post date:** [March 4, 2026, 8:54am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/8 "2026-03-04T08:54:01Z")

</div>

Is this problem solved? In which version? When is it expected to be resolved?

---

<div class="post-metadata">

**Author:** ![Matan\_OX](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Matan\_OX](https://forum.cursor.com/u/Matan_OX)\
**Post date:** [March 5, 2026, 9:17am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/9 "2026-03-05T09:17:38Z")

</div>

Hi Colin, thanks for the response, any chance of getting an ETA?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [March 5, 2026, 10:59pm UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/10 "2026-03-05T22:59:58Z")

</div>

I don’t have an ETA to share yet, I’m sorry!

---

<div class="post-metadata">

**Author:** ![Bar\_Azouri](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Bar\_Azouri](https://forum.cursor.com/u/Bar_Azouri)\
**Post date:** [March 26, 2026, 2:48pm UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/11 "2026-03-26T14:48:29Z")

</div>

Hi,  
Would like to follow up on the status for this one. It’s blocked us from using hooks in Cursor. Any ETA please?

---

<div class="post-metadata">

**Author:** ![Knne\_Villegas](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@Knne\_Villegas](https://forum.cursor.com/u/Knne_Villegas)\
**Post date:** [April 2, 2026, 6:22am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/12 "2026-04-02T06:22:03Z")

</div>

啥时解决啊

---

<div class="post-metadata">

**Author:** ![cp\_peck](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@cp\_peck](https://forum.cursor.com/u/cp_peck)\
**Post date:** [April 14, 2026, 2:45am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/13 "2026-04-14T02:45:01Z")

</div>

cursor 3.0.16 still has this problem

---

<div class="post-metadata">

**Author:** ![cp\_peck](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@cp\_peck](https://forum.cursor.com/u/cp_peck)\
**Post date:** [April 15, 2026, 12:25pm UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/14 "2026-04-15T12:25:11Z")

</div>

I encountered this issue on both Linux (remote SSH) and Windows.

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [April 22, 2026, 7:16am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/17 "2026-04-22T07:16:03Z")

</div>

Hey @_lonelywaitingliu ,  
The ENAMETOOLONG error when hooks receive large file payloads has been fixed, it will be included in a future stable update. If you’re on an early access track, updating to the latest version may already include the fix.

cc @Matan_OX @weixiang @Bar_Azouri @Knne_Villegas @cp_peck

---

<div class="post-metadata">

**Author:** ![weixiang](https://avatars.discourse-cdn.com/v4/letter/w/9fc348/32.png) [@weixiang](https://forum.cursor.com/u/weixiang)\
**Post date:** [May 7, 2026, 1:57am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/20 "2026-05-07T01:57:55Z")

</div>

> [@Matan\_OX](#):
>
> k

> [@mohitjain](#):
>
> The ENAMETOOLONG error when hooks receive large file payloads has been fixed, it will be included in a future stable update. If you’re on an early access track, updating to the latest version may already include the fix.

Thanks for the update! It’s great to hear that the `ENAMETOOLONG` error is fixed.

I have a couple of questions regarding the release schedule:

1. Is there a specific version number planned for this fix?

2. Do you have an estimated timeline for when this will be merged into the official stable release?

Looking forward to it!

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [May 7, 2026, 10:20am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/21 "2026-05-07T10:20:01Z")

</div>

@weixiang - The fix is already available on the current stable release. Updating Cursor should resolve the issue: `Ctrl+Shift+P` \> Attempt Update, then restart.

Let us know if the problem persists after updating.

---

<div class="post-metadata">

**Author:** ![cp\_peck](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@cp\_peck](https://forum.cursor.com/u/cp_peck)\
**Post date:** [May 26, 2026, 9:12am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/22 "2026-05-26T09:12:10Z")

</div>

When the file has more than 17,000 lines, this issue still occurs in Cursor(Version: 3.5.33,) on my Mac.

 ![image](https://us1.discourse-cdn.com/cursor1/original/3X/4/d/4d2e5d60caa0d75bb126d38bddf5ef4d3d5e6bf7.png) @Colin @mohitjain

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [May 26, 2026, 11:44am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/24 "2026-05-26T11:44:12Z")

</div>

The error you’re seeing (`spawn E2BIG`) is actually a different error from the original `ENAMETOOLONG` that was fixed. The earlier fix resolved the issue on Windows, but on macOS, when the file content exceeds a certain size (which a 17,000+ line file would), the hook payload hits a different OS-level limit that the original fix didn’t cover.

This is a known issue that our team is actively working on. Unfortunately there’s no workaround at the moment since it’s a limitation in how the hook payload is delivered to the script on macOS/Linux.

We’ll update this thread once the fix ships.

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [August 11, 2026, 7:49am UTC](https://forum.cursor.com/t/pretooluse-hook-fails-with-enametoolong-for-large-files/150346/26 "2026-08-11T07:49:05Z")

</div>

Large hook payloads no longer go through process args, so `ENAMETOOLONG` and `E2BIG` on `preToolUse` / `afterFileEdit` should be gone on current stable. Update Cursor, keep reading the hook input from stdin, and reply here if it still happens.
