nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.44k stars 276 forks source link

[Question]: How to emulate a true .exit() command in browser? #4301

Closed MarketingPip closed 1 month ago

MarketingPip commented 7 months ago

Details

I am almost positive this in impossible unless using a web worker, but is there any way we can "stop" code including any / all awaiting promises.

Similar to command line exit / terminated process?

Node.js version

Not applicable.

Example code

No response

Operating system

Any.

Scope

Question.

Module and version

Not applicable.

ljharb commented 7 months ago

This isn’t a node question, it’s a browser one - and no, in a browser there’s no way to do anything but throw an exception or navigate to another page, afaik.

MarketingPip commented 7 months ago

This isn’t a node question, it’s a browser one - and no, in a browser there’s no way to do anything but throw an exception or navigate to another page, afaik.

My apologizies if wrong area. Just figured I might have some luck finding something that I do not know about. Not sure how to cancel ANY all awaiting processes.

ljharb commented 7 months ago

Again, in the browser, I'm pretty sure you can't unless you navigate the page elsewhere.

This should be closed, and if you have further questions you'd probably want to ask in WhatWG forums.

MarketingPip commented 7 months ago

@ljharb I know this is browser based but I do think this will be a Node.JS solution.

Possibly web containers etc.... ie; Node.js solution for this possibly.

Hence hoping for some other input or maybe other alternatives.

ljharb commented 7 months ago

It would be impossible for node to provide browsers a capability like that they they do not have. I’m afraid you’re out of luck.

MarketingPip commented 7 months ago

Again @ljharb - I think you should look at web containers. I think I am barking up the right tree.

ljharb commented 7 months ago

That might let you exit the container, but wouldn’t ever affect the main thread, and again, wouldn’t involve node at all.

github-actions[bot] commented 1 month ago

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.