rogchap / v8go

Execute JavaScript from Go

Home Page:https://rogchap.com/v8go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`iso.TerminateExecution()` doesn't work

Thearas opened this issue · comments

Failed to terminate the infinite loop:

func TestIsolateTerminateExecution2(t *testing.T) {
	iso := v8.NewIsolate()
	ctx := v8.NewContext(iso)

	defer func() {
		ctx.Close()
		iso.Dispose()
	}()

	val, err := ctx.RunScript(`for (i = 0; ; i++) {}`, "javascript")
	if err != nil {
		panic(err)
	}
	jsFn, err := val.AsFunction()
	if err != nil {
		panic(err)
	}

	go func() {
		jsFn.Call(v8.Undefined(iso))
	}()
	time.Sleep(time.Second)

	// Doesn't Work
	iso.TerminateExecution()
}