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

process.on is not implemented #153

Open
2 tasks
floydspace opened this issue Feb 13, 2024 · 2 comments
Open
2 tasks

process.on is not implemented #153

floydspace opened this issue Feb 13, 2024 · 2 comments
Labels
enhancement New feature or request javascript Pull requests that update Javascript code rust Pull requests that update Rust code

Comments

@floydspace
Copy link
Contributor

floydspace commented Feb 13, 2024

I'd like to gracefully shutdown my lambda

However, looks like LLRT has no process.on('SIGTERM', ... implemented yet

Tasks

@richarddavison richarddavison added enhancement New feature or request javascript Pull requests that update Javascript code rust Pull requests that update Rust code labels Feb 14, 2024
@AKushWarrior
Copy link

@richarddavison In Node, process is a global instance of EventEmitter, which itself has a wide API surface. Right now, process is implemented as a singleton, ignoring the inherited behavior from EventEmitter. Architecturally, would implementing process.on be a (relatively simple) matter of defining the signals for that method/emitter, or part of a larger effort to implement node:events?

The upside to only implementing process.on (as I see it) is that it significantly reduces the implementation complexity of this issue, which seems fairly important for practical usage in a lambda context; on the other hand, it would introduce more refactoring work and technical debt if/when node:events is ever implemented.

@richarddavison
Copy link
Contributor

Hi @AKushWarrior! You are correct. There is no problem migrating process to extend event emitter.
The high-level binding lib does not (yet) support this but we can achieve the same effect by using something like eval("class Process extends EventEmitter") from Rust, and add methods to it's prototype.

The tricky part is to asynchronously react to signals. rquickjs in its current state does not expose a mechanism to react to "ticks" asynchronously. But we need to sort this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code rust Pull requests that update Rust code
Projects
None yet
Development

No branches or pull requests

3 participants