Hook execution reports 8+ seconds delay despite actual execution taking only 5ms

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The beforeSubmitPrompt hook infrastructure reports extremely long execution times (7-9 seconds), even though the actual hook script completes in under 10ms.

Command: node ./hooks/log-prompt-test.js (7485ms) exit code: 0

Cursor reports hook execution as 7500+ ms while internal timing logs show:

[prompt] Script started at: 1767001406216
[prompt] Received chunk at: 4 ms
[prompt] stdin ended at: 5 ms
[prompt] hi
[prompt] Processing done at: 5 ms

Steps to Reproduce

Create a minimal hook script that only prints and exits:

#!/usr/bin/env node
const startTime = Date.now();
console.error('[prompt] Script started at:', startTime);

let inputData = '';

process.stdin.setEncoding('utf8');

process.stdin.on('data', (chunk) => {
  console.error('[prompt] Received chunk at:', Date.now() - startTime, 'ms');
  inputData += chunk;
});

process.stdin.on('end', () => {
  console.error('[prompt] stdin ended at:', Date.now() - startTime, 'ms');
  
  try {
    const input = JSON.parse(inputData);
    const prompt = input.prompt || '';
    
    console.error('[prompt]', prompt);
    console.error('[prompt] Processing done at:', Date.now() - startTime, 'ms');
    
    console.log(JSON.stringify({ continue: true }));
  } catch (error) {
    console.log(JSON.stringify({ continue: true }));
  }
});

Register it in hooks.json

{
  "version": 1,
  "hooks": {
    "beforeSubmitPrompt": [
      {
        "command": "node ./hooks/log-prompt.js"
      }
    ]
  }
}

Submit a prompt and observe the reported hook execution time, in the example of logs, we sent a simple “Hi”.

Expected Behavior

Hook execution time should reflect actual script runtime (5-10ms). Hook execution overhead should be in the range of a few hundred milliseconds, not 7-9 seconds.

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.2.43 (user setup)
VSCode Version: 1.105.1
Commit: 32cfbe848b35d9eb320980195985450f244b3030
Date: 2025-12-19T06:06:44.644Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

Claude Opus 4.5, Claude Sonnet 4.5

Additional Information

Device: Dell Latitude 5540
Processor: 13th Gen Intel Core i7-1370P
RAM: 32 GB DDR5 4800 MT/s

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report.

This is a known issue caused by Windows process startup overhead for hooks. Even minimal hooks can be noticeably slower on Windows than on macOS. The team is already working on improving hook performance on Windows.

See also: Similar report for the beforeTabFileRead hook

Since beforeSubmitPrompt runs less often than tab-related hooks, the impact should be lower, but the overhead is still noticeable. We’ll track this alongside the existing Windows hook performance improvements.

Hello @deanrie , is there any news regarding this issue?

Hey @Iheb_HASNI!

We’re shipping some speed improvements to hooks where we we no longer launch a full instance of the user’s Zsh shell. I have a feeling this is where the latency is coming from in reporting the delay.

It’s on nightly now if you’d like to give it a try!

1 Like