(t *testing.T)
| 655 | } |
| 656 | |
| 657 | func TestContextLoadModuleAsyncPromiseExecutorTimeout(t *testing.T) { |
| 658 | rt := NewRuntime(WithModuleImport(true), WithExecuteTimeout(1)) |
| 659 | defer rt.Close() |
| 660 | |
| 661 | ctx := rt.NewContext() |
| 662 | require.NotNil(t, ctx) |
| 663 | defer ctx.Close() |
| 664 | |
| 665 | start := time.Now() |
| 666 | result := ctx.LoadModule(` |
| 667 | export default 123; |
| 668 | await new Promise((res, rej) => { |
| 669 | // keep pending forever to exercise timeout fallback |
| 670 | }); |
| 671 | `, "issue_471_async_executor") |
| 672 | defer result.Free() |
| 673 | |
| 674 | elapsed := time.Since(start) |
| 675 | require.True(t, result.IsException()) |
| 676 | |
| 677 | err := ctx.Exception() |
| 678 | require.Error(t, err) |
| 679 | require.Contains(t, err.Error(), "interrupted") |
| 680 | require.Less(t, elapsed, 3*time.Second) |
| 681 | } |
| 682 | |
| 683 | func TestContextLoadModuleAsyncPromiseExecutorUnhandledRejection(t *testing.T) { |
| 684 | rt := NewRuntime(WithModuleImport(true), WithExecuteTimeout(30)) |
nothing calls this directly
no test coverage detected