Skip to content

Fix: helloworld-sample #1159#1265

Open
ShubhamRoy123 wants to merge 8 commits intomicrosoft:mainfrom
ShubhamRoy123:main
Open

Fix: helloworld-sample #1159#1265
ShubhamRoy123 wants to merge 8 commits intomicrosoft:mainfrom
ShubhamRoy123:main

Conversation

@ShubhamRoy123
Copy link

@ShubhamRoy123 ShubhamRoy123 commented Jan 26, 2026

This PR fixes the issue where the helloworld-sample fails to compile automatically when pressing F5 on Windows.

The preLaunchTask was not correctly triggering the TypeScript compilation (npm: watch), resulting in a missing out directory and a "command not found" error when trying to run the extension. I have updated the task configuration to ensure it executes reliably across different Windows shell environments.

Related Issues
Closes #1159

Checklist
[x] I have tested these changes locally on Windows.

[x] The out directory is now correctly generated upon pressing F5.

[x] The "Hello World" command works immediately in the Extension Development Host.

@ShubhamRoy123
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Author

@ShubhamRoy123 ShubhamRoy123 left a comment

Choose a reason for hiding this comment

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

"LGTM" (Looks Good To Me) and please clicking an approve button.

@ShubhamRoy123
Copy link
Author

ShubhamRoy123 commented Jan 29, 2026

Hi @mjbvz , I’ve addressed the issue where helloworld-sample failed to compile on Windows due to the preLaunchTask not correctly triggering TypeScript compilation.
I have updated the task configuration to ensure it executes reliably across different Windows shell environments and confirmed that the out directory is now correctly generated.
I also attatch .patch file from a protips advice.
Could you please review and approve these changes when you have a moment? Thanks!

@ShubhamRoy123 ShubhamRoy123 changed the title Fix: Ensure preLaunchTask triggers compilation on Windows #1159 Fix: helloworld-sample #1159 Jan 30, 2026
Copy link

Choose a reason for hiding this comment

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

Muy bien
Creación

@ShubhamRoy123
Copy link
Author

Muy bien Creación

Thank you for the review! I have cleaned up the branch and synced it with the latest main. Ready for a final check.

@eljoeepf-ui
Copy link

eljoeepf-ui commented Feb 8, 2026 via email

@ShubhamRoy123
Copy link
Author

@mjbvz good day sir , sir please i request to you to check my pr request . your small contribution is very helpful for me. and my future🙏

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 9, 2026

Thanks for taking a look. If watch isn't working, let's fix the root cause of that instead of trying to work around it

For what it's worth, the current setup seems to work fine for me on a Mac

@ShubhamRoy123
Copy link
Author

Thanks for taking a look. If watch isn't working, let's fix the root cause of that instead of trying to work around it

For what it's worth, the current setup seems to work fine for me on a Mac

Thanks for the feedback, sir @mjbvz! I understand what i need to do next.

@ShubhamRoy123
Copy link
Author

Thanks for taking a look. If watch isn't working, let's fix the root cause of that instead of trying to work around it

For what it's worth, the current setup seems to work fine for me on a Mac

@mjbvz Good day sir . I have identified the root cause as a race condition
i updated a tasks.json file and also sorry for late because i was test this extension on linux also with the help of docker.

Also I changed back from "npm: compile" to "npm:watch"
can you also review my changes. 🙏🙏

@lukas-2803
Copy link

lukas-2803 commented Feb 12, 2026 via email

@ShubhamRoy123
Copy link
Author

ShubhamRoy123 commented Feb 12, 2026

@lukas-2803 good day sir
actually what is happening here
according to issue #1159
i saw an error
WhatsApp Image 2026-02-12 at 9 17 52 PM
so i understand that the Compiler (tsc -w) and the Extension Host (the debugger) both start at the same time.
then i changed npm : watch to npm : compile but the problem is "In compile mode, every time you change a single line of code in your extension.ts, you have to stop the debugger and manually run the build again. " and
According to @mjbvz sir he suggest me instead of changing watch fix root cause and then i was working on this and i understand it's actually a race condition problem
the Compiler and the Debugger—start at the same time and "race" to access the same files. Because they aren't synchronized, the outcome depends entirely on which one finishing first.
On a machine with high I/O latency (like Windows 11), the Debugger often "wins" the race.
but if cpu is busy (high latency), there is a significant 'lag' between starting the task and the files appearing in the out directory. Without synchronization, the Debugger reaches for the entry point while it is still missing or being written, resulting in the 'Command not found' error.(which you see on screenshot)
you can think like you run this extension in old cpu laptop which is high latency where this error is guaranteed to show up. example :-"pentium cpu"

My Solution: I implemented a Background Problem Matcher in tasks.json that acts as a 'Safety Gate.'
*beginsPattern: Configured to detect the initial compilation message in the terminal. Technically, this signals to VS Code's task system that the background process is in an active/non-ready state, effectively blocking the dependent Debugger from attaching.

*endsPattern: Specifically targets the Found 0 errors. Watching for file changes. success string. Matching this pattern transitions the task state to "idle/ready," which acts as the release signal for the Extension Development Host.

Why this Fixes the Root Cause:-
1)Serialization of Parallel Processes: By using these patterns, I have converted an unpredictable parallel start into a serialized sequence. The Debugger is now programmatically prevented from attempting to load the extension entry point until the disk write operation is confirmed complete by the compiler.

2)Latency Independence: This ensures that even under high CPU load or I/O latency (which frequently occurs on Windows 11), the Extension Host will never encounter a missing out/extension.js file.

3)Preserved Incremental Workflow: Unlike switching to a standard compile task, this keeps the Background Watcher active, allowing for fast, incremental updates without losing the synchronization safety.

@lukas-2803
Copy link

lukas-2803 commented Feb 12, 2026 via email

@ShubhamRoy123
Copy link
Author

@mjbvz good day sir , can you please review tasks.json file and approve my pr?🙏
Following your earlier suggestion, I have identified and fixed the root cause of the race condition

@mjbvz mjbvz requested a review from meganrogge February 13, 2026 18:11
@ShubhamRoy123
Copy link
Author

ShubhamRoy123 commented Feb 15, 2026

@meganrogge , good day Mam.

I have finalized the fix for the race condition in the helloworld-sample on Windows. Following @mjbvz's suggestion, I identified the root cause: the debugger was attempting to activate before the background watch task could finish writing the out directory.

My solution implements a deterministic synchronization handshake using a problemMatcher in tasks.json. This ensures the extension is only activated once the build success signal is received, making it 100% reliable even on high-latency systems.

I have verified this locally on Windows and docker ubuntu. Could you please do a final review? 🙏

@ShubhamRoy123
Copy link
Author

Good day @mjbvz sir ,and @meganrogge mam I hubble request to you please if you take some miner time and give some updates of my pr

@ShubhamRoy123
Copy link
Author

@mjbvz good day sir , sir please i request you again to check my pr request . your small contribution is very helpful for me. and my future🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hello world - Compilation didn't run at the launch of the extension (press F5)

5 participants