Skip to content

How to monitor js_runtime or js_context healthness and gracefully shutdown after specified timeout #331

Description

@laishere

Scene:
I want to run a js script in a runtime. The js code may be malformed. For example, infinite loop may happens in normal functions or Promise jobs.

I want to specify a timeout to shutdown context or runtime. When the context or runtime can't make any response after a timeout.
I want to know what's the best way to do this.

I have some thoughts in my mind:

  1. Use alarm signal: when the alarm is reached, do something to stop stack machine. Do we have this kind of approch to stop stack machine without droping performance like inserting a byte code or altering the PC to a particular location?
  2. Stop the runtime worker thread immediately when monitor thread detects it can't make any response. Which means that the runtime may stop at any instruction point. Can we make sure that we free all the resource after this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions