Skip to content

Spawn vscode on demand #4499

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

Merged
merged 6 commits into from
Nov 15, 2021
Merged

Spawn vscode on demand #4499

merged 6 commits into from
Nov 15, 2021

Conversation

GirlBossRush
Copy link
Contributor

Fixes #4481

@GirlBossRush GirlBossRush added bug Something isn't working enhancement Some improvement that isn't a feature labels Nov 11, 2021
@GirlBossRush GirlBossRush added this to the 4.0.0 milestone Nov 11, 2021
@GirlBossRush GirlBossRush self-assigned this Nov 11, 2021
@GirlBossRush GirlBossRush requested a review from a team as a code owner November 11, 2021 23:03
@github-actions
Copy link

github-actions bot commented Nov 11, 2021

✨ Coder.com for PR #4499 deployed! It will be updated on every commit.

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Thank you for doing this! I know it sucks to maintain legacy behavior. Once plugins are removed we can revert this behavior as well if we want. 😄

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

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

Nice work!

Comment on lines +144 to +146
for (const routePrefix of ["/", "/vscode"]) {
app.router.use(routePrefix, vsServerRouteHandler.router)
app.wsRouter.use(routePrefix, vsServerRouteHandler.wsRouter)
Copy link
Contributor

Choose a reason for hiding this comment

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

so much cleaner 👏

router.all("*", ensureAuthenticated, (req, res, next) => {
req.on("error", (error: any) => {
private $proxyRequest: express.Handler = async (req, res, next) => {
// We allow certain errors to propagate so that other routers may handle requests
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

❓ why start the name with $? is that some sort of special pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s something of a convention I’ve seen help with readability, similarly to prefixing private methods with _. Prefixing a method like $proxyRequest helps indicate a unique purpose compared to a more lengthy proxyRequestHandler


try {
this._codeServerMain = await createVSServer(null, {
connectionToken: "0000",
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ What's the connectionToken used for again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Connection token is used by VS Code as a basic form of client-side security. At the moment we’ve disabled its usage, but I think it’s worth looking at again as upstream matures the feature.

Copy link
Member

Choose a reason for hiding this comment

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

Related: #4479

@code-asher
Copy link
Member

code-asher commented Nov 12, 2021

One observation (this is not from this PR since I remember seeing this before) but I get a 404 when VS Code is still loading rather than the "VS Code may still be compiling" error (running yarn watch). For a new developer this could be unexpected.

404

@GirlBossRush GirlBossRush force-pushed the 4481-spawn-vscode-on-demand branch from b80725d to e56d970 Compare November 12, 2021 17:55
@codecov
Copy link

codecov bot commented Nov 12, 2021

Codecov Report

Merging #4499 (f2b3156) into main (6606040) will decrease coverage by 0.52%.
The diff coverage is 65.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4499      +/-   ##
==========================================
- Coverage   66.46%   65.93%   -0.53%     
==========================================
  Files          30       30              
  Lines        1625     1638      +13     
  Branches      330      330              
==========================================
  Hits         1080     1080              
- Misses        463      475      +12     
- Partials       82       83       +1     
Impacted Files Coverage Δ
src/node/routes/vscode.ts 50.00% <57.57%> (-5.56%) ⬇️
src/node/routes/index.ts 79.77% <100.00%> (+2.93%) ⬆️
src/node/util.ts 76.88% <0.00%> (-3.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6606040...f2b3156. Read the comment docs.

@jsjoeio jsjoeio removed this from the 4.0.0 milestone Nov 12, 2021
Teffen and others added 4 commits November 14, 2021 19:17
* Fix : recreate the termux guide to adapt the recent changes

Termux nodejs-lts changed from v14 to v16 and there are many issues people are facing such as with argon2. Hence I recommend changing it to this install process which is comparably better and has one less issue :^)

I've also added some extra things such as installing GO and Python, idk about the TOC tree but this is pretty much it.

* yarn-fmt and minor typos

#4472 (comment)

* Fix : replace unnecessary steps to be linked to a guide

* Change from private gist to a section in Extra

* Remove reference to non-existent step

* ready to merge!

Co-authored-by: Joe Previte <[email protected]>
@GirlBossRush GirlBossRush merged commit e705948 into main Nov 15, 2021
@GirlBossRush GirlBossRush deleted the 4481-spawn-vscode-on-demand branch November 15, 2021 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Some improvement that isn't a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spawn VS Code on demand to avoid overhead
5 participants