Skip to content
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

set_terminate does not work. #20

Closed
samchon opened this issue Nov 13, 2018 · 1 comment
Closed

set_terminate does not work. #20

samchon opened this issue Nov 13, 2018 · 1 comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects

Comments

@samchon
Copy link
Owner

samchon commented Nov 13, 2018

Summary

  • TSTL Version: 2.0.10
  • Expected behavior: set_terimnate should assure the parameterized function to be called in all the time.
  • Actual behavior: Not works in all the time. Only works when the program is halt by uncaught exception. Also, if the set_terimnate function is used, it removes ordinary handler function of
    the uncaught exception enrolled by the on method.

Code occuring the bug

Until now, I had known that catching termination event is not possible in the browser environment. Thus, I'd programmed the set_terminate to run only when the program is halted by uncaught exception exists. However, it was not true. Catching termination event is possible in most case.

export function set_terminate(func: () => void): void
{
	_Get_root().__s_pTerminate_handler = func;
	
	if (is_node() === true)
		process.on("uncaughtException", function (): void
		{
			_Get_root().__s_pTerminate_handler();
		});
	else
		self.onerror = function (): void
		{
			_Get_root().__s_pTerminate_handler();
		};
}
@samchon samchon added the bug Something isn't working label Nov 13, 2018
@samchon samchon added this to To do in v2.1 Update via automation Nov 13, 2018
@samchon samchon added enhancement New feature or request help wanted Extra attention is needed labels Nov 13, 2018
@samchon samchon moved this from To do to In progress in v2.1 Update Nov 13, 2018
@samchon
Copy link
Owner Author

samchon commented Nov 13, 2018

I've wrote an update code, but it does not ensure the "run in all the time" yet.

It guarantees exact activity for the Browser or NodeJS environment, however, not for Worker yet. In the Worker, I'm using close event which is not standard feature (to be deprecated) and not supported in the all browser. If anyone knows the solution, then please inform me or send a PR.

@samchon samchon moved this from In progress to Done in v2.1 Update Nov 28, 2018
@samchon samchon moved this from Done to On review in v2.1 Update Nov 30, 2018
@samchon samchon moved this from On review to Done in v2.1 Update Dec 12, 2018
@samchon samchon closed this as completed Dec 12, 2018
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 New feature or request help wanted Extra attention is needed
Projects
No open projects
v2.1 Update
  
Done
Development

No branches or pull requests

1 participant