worker.runUntil has a ShutdownError

I’m running a jest test on my workflow and once the workflow is successfully done the worker.runUntil has a ShutdownError: “Worker failed { error: [Error [ShutdownError]: ShutDown]”.

The logs say:

2023-07-12T20:18:20.223978Z  INFO temporal_sdk_core::worker: Initiated shutdown task_queue=test namespace=default
2023-07-12T20:18:20.224390Z  INFO temporal_sdk_core::worker::workflow::workflow_stream: Workflow shutdown is done
2023-07-12T20:18:20.223Z [INFO] Worker state changed { state: 'STOPPING' }
2023-07-12T20:18:20.224Z [INFO] Worker state changed { state: 'DRAINING' }
2023-07-12T20:18:20.226Z [ERROR] Worker failed { error: [Error [ShutdownError]: ShutDown] }
2023-07-12T20:18:20.227Z [INFO] Worker state changed { state: 'FAILED' }

I’m running on 1.8.1 for all temporal node_modules involved.
@temporalio/activity”: “^1.8.1”,
@temporalio/client”: “^1.8.1”,
@temporalio/nyc-test-coverage”: “^1.8.1”,
@temporalio/testing”: “^1.8.1”,
@temporalio/worker”: “^1.8.1”,
@temporalio/workflow”: “^1.8.1”,

Am I doing something wrong here?
What could cause the shutdown error?
Thank you for your help!

This is a regression introduced in 1.8.0 which was improperly fixed in 1.8.1.

Jest uses a different v8 context for setup code and each test causing the SDK’s instanceof Error checks to fail.

This PR will fix the issue and should be included in the 1.8.2 release shortly.

We’re no longer recommending using Jest with the SDK due to repeated issues such as this one.
There’s another open issue with Jest and test coverage in workflows that we will likely not be able to fix in the near future.

1 Like

Thank you for pushing out the fix, I’m looking forward to it.
Regarding jest, we’re using it in multiple projects and workflows are part of a larger mono-repo that uses jest so it would not be ideal to change that. With that, we’re hoping that temporal will continue to support jest.

Thank you!