workers-runtime-sdk 1.8.6__tar.gz → 1.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/CHANGELOG.md +13 -0
  2. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/PKG-INFO +1 -1
  3. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/pyproject.toml +1 -1
  4. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/entrypoints.py +22 -2
  5. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/utils.py +35 -1
  6. workers_runtime_sdk-1.9.0/src/workers/workflows.js +91 -0
  7. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_workflow.py +11 -1
  8. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/worker_workflow.py +20 -4
  9. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/test_in_workerd.py +17 -4
  10. workers_runtime_sdk-1.9.0/tests/workerd-test/workflow/pyproject.toml +5 -0
  11. workers_runtime_sdk-1.9.0/tests/workerd-test/workflow/worker.js +112 -0
  12. workers_runtime_sdk-1.9.0/tests/workerd-test/workflow/worker.py +72 -0
  13. workers_runtime_sdk-1.9.0/tests/workerd-test/workflow/workflow.wd-test +30 -0
  14. workers_runtime_sdk-1.9.0/tests/workerd-test/workflow/wrangler.jsonc +5 -0
  15. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/uv.lock +1 -1
  16. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/.gitignore +0 -0
  17. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/AGENTS.md +0 -0
  18. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/README.md +0 -0
  19. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/_cloudflare_compat_flags.pyi +0 -0
  20. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/_pyodide_entrypoint_helper.pyi +0 -0
  21. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/_workers_sdk_entropy_import_context.py +0 -0
  22. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/_workers_sdk_package_patches.py +0 -0
  23. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/_workers_sdk_patch_loader.pth +0 -0
  24. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/_workers_sdk_patch_loader.py +0 -0
  25. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/asgi.py +0 -0
  26. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/__init__.py +0 -0
  27. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/asgi.py +0 -0
  28. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/blob.py +0 -0
  29. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/fetch.py +0 -0
  30. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/formdata.py +0 -0
  31. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/py.typed +0 -0
  32. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/request.py +0 -0
  33. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/response.py +0 -0
  34. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/rpc.py +0 -0
  35. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/types.py +0 -0
  36. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/workflows.py +0 -0
  37. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/src/workers/wsgi.py +0 -0
  38. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/public/data.json +0 -0
  39. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/public/hello.txt +0 -0
  40. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/pyproject.toml +0 -0
  41. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/conftest.py +0 -0
  42. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_analytics_engine.py +0 -0
  43. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_assets.py +0 -0
  44. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_d1.py +0 -0
  45. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_do.py +0 -0
  46. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_hyperdrive_mysql.py +0 -0
  47. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_hyperdrive_postgresql.py +0 -0
  48. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_images.py +0 -0
  49. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_kv.py +0 -0
  50. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_mtls.py +0 -0
  51. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_queue.py +0 -0
  52. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_r2.py +0 -0
  53. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_ratelimit.py +0 -0
  54. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_vectorize.py +0 -0
  55. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/test_version_metadata.py +0 -0
  56. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/worker.py +0 -0
  57. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/src/worker_durable_object.py +0 -0
  58. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/bindings-test/wrangler.jsonc +0 -0
  59. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/conftest.py +0 -0
  60. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/test_bindings.py +0 -0
  61. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/test_fastapi.py +0 -0
  62. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/test_flask.py +0 -0
  63. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/test_web_frameworks.py +0 -0
  64. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/pyproject.toml +0 -0
  65. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/_client.py +0 -0
  66. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/conftest.py +0 -0
  67. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/__init__.py +0 -0
  68. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/api_urls.py +0 -0
  69. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/auth_backend.py +0 -0
  70. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/drf_auth.py +0 -0
  71. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/drf_serializers.py +0 -0
  72. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/drf_throttling.py +0 -0
  73. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/drf_views.py +0 -0
  74. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/forms.py +0 -0
  75. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/middleware.py +0 -0
  76. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/templatetags/__init__.py +0 -0
  77. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/templatetags/custom_tags.py +0 -0
  78. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/urls.py +0 -0
  79. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/django_app/views.py +0 -0
  80. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/templates/base.html +0 -0
  81. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/templates/context_test.html +0 -0
  82. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/templates/csrf_form.html +0 -0
  83. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/templates/hello.html +0 -0
  84. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_async_utilities.py +0 -0
  85. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_auth.py +0 -0
  86. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_caching.py +0 -0
  87. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_cors.py +0 -0
  88. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_csrf.py +0 -0
  89. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_drf_auth_permissions.py +0 -0
  90. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_drf_content_negotiation.py +0 -0
  91. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_drf_serializers.py +0 -0
  92. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_drf_throttling.py +0 -0
  93. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_drf_versioning.py +0 -0
  94. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_drf_views.py +0 -0
  95. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_error_handling.py +0 -0
  96. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_file_uploads.py +0 -0
  97. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_forms.py +0 -0
  98. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_middleware.py +0 -0
  99. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_pagination.py +0 -0
  100. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_request_response.py +0 -0
  101. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_sessions.py +0 -0
  102. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_signals.py +0 -0
  103. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_streaming.py +0 -0
  104. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_templates.py +0 -0
  105. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_url_routing.py +0 -0
  106. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/test_views_basic.py +0 -0
  107. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/src/worker.py +0 -0
  108. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/django-async/wrangler.jsonc +0 -0
  109. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/public/data.json +0 -0
  110. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/public/index.html +0 -0
  111. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/public/style.css +0 -0
  112. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/pyproject.toml +0 -0
  113. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/_client.py +0 -0
  114. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/conftest.py +0 -0
  115. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/static/app.css +0 -0
  116. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/static/data.json +0 -0
  117. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/static/hello.txt +0 -0
  118. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/static/index.html +0 -0
  119. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_assets.py +0 -0
  120. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_error_handling.py +0 -0
  121. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_platform_boundaries.py +0 -0
  122. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_platform_io.py +0 -0
  123. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_platform_lifecycle.py +0 -0
  124. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_response_types.py +0 -0
  125. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_routing.py +0 -0
  126. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_staticfiles.py +0 -0
  127. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_sync_handlers.py +0 -0
  128. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/test_websocket.py +0 -0
  129. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/src/worker.py +0 -0
  130. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/fastapi-tests/wrangler.jsonc +0 -0
  131. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/flask-tests/pyproject.toml +0 -0
  132. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/flask-tests/src/test_response.py +0 -0
  133. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/flask-tests/src/worker.py +0 -0
  134. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/web-frameworks-test/flask-tests/wrangler.jsonc +0 -0
  135. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi/asgi.wd-test +0 -0
  136. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi/pyproject.toml +0 -0
  137. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi/tests/test_asgi.py +0 -0
  138. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi/worker.py +0 -0
  139. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi/wrangler.jsonc +0 -0
  140. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi-ws-disconnect/asgi-ws-disconnect.wd-test +0 -0
  141. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi-ws-disconnect/pyproject.toml +0 -0
  142. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi-ws-disconnect/tests/test_ws_disconnect.py +0 -0
  143. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi-ws-disconnect/worker.py +0 -0
  144. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/asgi-ws-disconnect/wrangler.jsonc +0 -0
  145. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object/durable-object.wd-test +0 -0
  146. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object/pyproject.toml +0 -0
  147. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object/worker.py +0 -0
  148. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object/wrangler.jsonc +0 -0
  149. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-abort/durable-object-abort.wd-test +0 -0
  150. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-abort/pyproject.toml +0 -0
  151. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-abort/worker.py +0 -0
  152. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-abort/wrangler.jsonc +0 -0
  153. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-inheritance/durable-object-inheritance.wd-test +0 -0
  154. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-inheritance/pyproject.toml +0 -0
  155. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-inheritance/worker.py +0 -0
  156. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-inheritance/wrangler.jsonc +0 -0
  157. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-websocket/durable-object-websocket.wd-test +0 -0
  158. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-websocket/pyproject.toml +0 -0
  159. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-websocket/tester.js +0 -0
  160. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-websocket/worker.py +0 -0
  161. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/durable-object-websocket/wrangler.jsonc +0 -0
  162. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/entropy-patches.wd-test +0 -0
  163. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/pyproject.toml +0 -0
  164. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_aiohttp_websocket.py +0 -0
  165. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_langsmith.py +0 -0
  166. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_litestar.py +0 -0
  167. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_mcp.py +0 -0
  168. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_numpy.py +0 -0
  169. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_opentelemetry.py +0 -0
  170. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_pydantic.py +0 -0
  171. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_rust_packages.py +0 -0
  172. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/tests/test_ssl_avoidance.py +0 -0
  173. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/worker.py +0 -0
  174. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/entropy-patches/wrangler.jsonc +0 -0
  175. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/http-client.wd-test +0 -0
  176. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/origin.py +0 -0
  177. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/pyproject.toml +0 -0
  178. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/tests/test_http_client.py +0 -0
  179. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/tests/test_urllib_request.py +0 -0
  180. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/worker.py +0 -0
  181. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/http-client/wrangler.jsonc +0 -0
  182. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/python-rpc/pyproject.toml +0 -0
  183. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/python-rpc/python-rpc.wd-test +0 -0
  184. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/python-rpc/worker.js +0 -0
  185. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/python-rpc/worker.py +0 -0
  186. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/python-rpc/wrangler.jsonc +0 -0
  187. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/sdk/pyproject.toml +0 -0
  188. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/sdk/sdk.wd-test +0 -0
  189. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/sdk/server.py +0 -0
  190. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/sdk/tests/test_sdk.py +0 -0
  191. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/sdk/worker.py +0 -0
  192. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/sdk/wrangler.jsonc +0 -0
  193. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/wsgi/pyproject.toml +0 -0
  194. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/wsgi/tests/test_wsgi.py +0 -0
  195. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/wsgi/worker.py +0 -0
  196. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/wsgi/wrangler.jsonc +0 -0
  197. {workers_runtime_sdk-1.8.6 → workers_runtime_sdk-1.9.0}/tests/workerd-test/wsgi/wsgi.wd-test +0 -0
@@ -2,6 +2,19 @@
2
2
 
3
3
  <!-- version list -->
4
4
 
5
+ ## v1.9.0 (2026-09-18)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **runtime-sdk**: Make NonRetryableError raised in a workflow step non-retryable
10
+ ([`1c1980a`](https://github.com/cloudflare/workers-py/commit/1c1980afabaa27d39bf18d3fe19c7385c2890fa6))
11
+
12
+ ### Features
13
+
14
+ - **runtime-sdk**: Add helpers to import JavaScript modules shipped with the SDK
15
+ ([`caa9364`](https://github.com/cloudflare/workers-py/commit/caa9364f38a111d5496f81f6bc23ebb88d191928))
16
+
17
+
5
18
  ## v1.8.6 (2026-09-18)
6
19
 
7
20
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: workers-runtime-sdk
3
- Version: 1.8.6
3
+ Version: 1.9.0
4
4
  Summary: Python SDK for Cloudflare Workers
5
5
  Project-URL: Homepage, https://github.com/cloudflare/workers-py
6
6
  Project-URL: Bug Tracker, https://github.com/cloudflare/workers-py/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "workers-runtime-sdk"
7
- version = "1.8.6"
7
+ version = "1.9.0"
8
8
  description = "Python SDK for Cloudflare Workers"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -17,7 +17,11 @@ from .rpc import (
17
17
  python_from_rpc,
18
18
  python_to_rpc,
19
19
  )
20
- from .utils import _from_js_error, _is_js_instance
20
+ from .utils import (
21
+ _from_js_error,
22
+ _is_js_instance,
23
+ import_sdk_javascript_module_async,
24
+ )
21
25
 
22
26
  if TYPE_CHECKING:
23
27
  from js import DurableObjectState, Env, ExecutionContext
@@ -294,6 +298,22 @@ def _wrap_class(cls):
294
298
  return cls
295
299
 
296
300
 
301
+ _workflows_js_module = None
302
+
303
+
304
+ async def _wrap_js_workflow_step(js_step):
305
+ """
306
+ Wrap the JS `WorkflowStep` stub with `wrapWorkflowStep` from the SDK's `workflows.js`.
307
+
308
+ The wrapper makes a Python `NonRetryableError` raised inside a step reach the Workflows
309
+ engine as a JS error the engine recognises as non-retryable (see `workflows.js`).
310
+ """
311
+ global _workflows_js_module # noqa: PLW0603
312
+ if _workflows_js_module is None:
313
+ _workflows_js_module = await import_sdk_javascript_module_async("workflows.js")
314
+ return _workflows_js_module.wrapWorkflowStep(js_step)
315
+
316
+
297
317
  def _wrap_workflow_step(cls):
298
318
  run_fn = cls.__dict__.get("run")
299
319
  if run_fn is None:
@@ -304,7 +324,7 @@ def _wrap_workflow_step(cls):
304
324
  if event is not None:
305
325
  event = python_from_rpc(event)
306
326
  if step is not None:
307
- step = _WorkflowStepWrapper(step)
327
+ step = _WorkflowStepWrapper(await _wrap_js_workflow_step(step))
308
328
 
309
329
  result = run_fn(self, event, step, *args, **kwargs)
310
330
 
@@ -126,6 +126,25 @@ def import_from_javascript(module_name: str) -> Any:
126
126
  raise
127
127
 
128
128
 
129
+ # Directory, relative to the worker bundle root, that `pywrangler sync` vendors Python packages
130
+ # into. wrangler registers `.js`/`.mjs` files found under `python_modules/workers/` as ES modules
131
+ # (everything else in `python_modules/` is opaque data), which is what lets them be imported via
132
+ # `import_from_javascript`.
133
+ _SDK_JS_MODULE_PREFIX = "python_modules/workers/"
134
+
135
+
136
+ async def import_sdk_javascript_module_async(name: str) -> Any:
137
+ """
138
+ Asynchronous function to import an sdk js module
139
+
140
+ This does not rely on JSPI, so it also works with Pyodide 0.26.0a2.
141
+ """
142
+ try:
143
+ return await _pyodide_entrypoint_helper.doAnImport(_SDK_JS_MODULE_PREFIX + name)
144
+ except JsException as e:
145
+ raise ImportError(f"Failed to import '{name}': {e}") from e
146
+
147
+
129
148
  @contextmanager
130
149
  def patch_env(
131
150
  d: dict[str, Any] | Sequence[tuple[str, Any]] | None = None, **kwds: dict[str, Any]
@@ -144,15 +163,30 @@ def _to_python_exception(exc: JsException) -> Exception:
144
163
  return exc
145
164
 
146
165
 
166
+ _NON_RETRYABLE_ERROR_NAME = "NonRetryableError"
167
+
168
+
147
169
  def _from_js_error(exc: JsException) -> Exception:
148
170
  # convert into Python exception after a full round trip
149
171
  # Python - JS - Python
150
172
  message = exc.message or ""
151
173
 
174
+ # A NonRetryableError raised inside a workflow step is translated by the
175
+ # runtime into a JS error named "NonRetryableError" before it reaches the
176
+ # Workflows engine, which is how the engine knows not to retry the step.
177
+ # When the engine rethrows it back to us the name either survives, or is
178
+ # folded into the message as a prefix.
179
+ if getattr(exc, "name", None) == _NON_RETRYABLE_ERROR_NAME:
180
+ return NonRetryableError(message)
181
+ if message == _NON_RETRYABLE_ERROR_NAME:
182
+ return NonRetryableError()
183
+ if message.startswith(_NON_RETRYABLE_ERROR_NAME + ": "):
184
+ return NonRetryableError(message[len(_NON_RETRYABLE_ERROR_NAME) + 2 :])
185
+
152
186
  # A Python exception that escaped to JS is a Pyodide `PythonError` whose
153
187
  # message is the formatted traceback. Depending on how it was serialized
154
188
  # over RPC it either keeps its name or arrives as a plain `Error` with
155
- # "PythonError: " folded into the message.
189
+ # "PythonError: " folded into the message
156
190
  if getattr(exc, "name", None) != "PythonError" and not message.startswith(
157
191
  "PythonError"
158
192
  ):
@@ -0,0 +1,91 @@
1
+ // JavaScript helpers for Python Workflows
2
+
3
+ const NON_RETRYABLE_ERROR_NAME = "NonRetryableError";
4
+
5
+ function isPythonError(e) {
6
+ return (
7
+ e instanceof Error &&
8
+ e.constructor?.name === "PythonError" &&
9
+ typeof e.type === "string"
10
+ );
11
+ }
12
+
13
+ // Extract the message the user passed to the Python exception from the
14
+ // traceback stored in `PythonError.message`.
15
+ //
16
+ // The last non-empty line of a formatted traceback is
17
+ // `<qualified.ExceptionType>: <message>`, or just `<qualified.ExceptionType>`
18
+ // when the exception was raised without a message. For example, given
19
+ //
20
+ // Traceback (most recent call last):
21
+ // File "/session/metadata/worker.py", line 19, in non_retryable
22
+ // raise NonRetryableError("do not retry")
23
+ // workers.workflows.NonRetryableError: do not retry
24
+ //
25
+ // this returns "do not retry", and given
26
+ //
27
+ // Traceback (most recent call last):
28
+ // File "/session/metadata/worker.py", line 34, in no_message
29
+ // raise NonRetryableError()
30
+ // workers.workflows.NonRetryableError
31
+ //
32
+ // it returns "".
33
+ function pythonExceptionMessage(e) {
34
+ const lines = e.message.split("\n").filter((line) => line.trim() !== "");
35
+ const last = lines.at(-1) ?? "";
36
+ const sep = last.indexOf(": ");
37
+ return sep === -1 ? "" : last.slice(sep + 2);
38
+ }
39
+
40
+ // Wraps a Python step callback passed to `WorkflowStep.do()`.
41
+ //
42
+ // If the error thrown is a Python NonRetryable error, translate it into a JS
43
+ // error that the engine will recognize as non retryable. Leave other errors
44
+ // alone.
45
+ export function wrapWorkflowStepCallback(pyCallback) {
46
+ return async function (...args) {
47
+ try {
48
+ return await pyCallback(...args);
49
+ } catch (e) {
50
+ if (isPythonError(e) && e.type === NON_RETRYABLE_ERROR_NAME) {
51
+ const err = new Error(pythonExceptionMessage(e));
52
+ err.name = NON_RETRYABLE_ERROR_NAME;
53
+ throw err;
54
+ }
55
+ throw e;
56
+ }
57
+ };
58
+ }
59
+
60
+ // Wraps the `WorkflowStep` RPC stub passed to a Python
61
+ // `WorkflowEntrypoint.run()` so that the callback given to `step.do()` goes
62
+ // through `wrapWorkflowStepCallback`.
63
+ //
64
+ // Because the wrapped `do` returns the stub's own promise, a Python callback
65
+ // passed to it keeps exactly the lifetime it would have had without the
66
+ // wrapper.
67
+ export function wrapWorkflowStep(step) {
68
+ // RPC stubs are callable, so `typeof step` is 'function'.
69
+ if (
70
+ step === null ||
71
+ (typeof step !== "object" && typeof step !== "function")
72
+ ) {
73
+ return step;
74
+ }
75
+ return new Proxy(step, {
76
+ apply(target, thisArg, args) {
77
+ return Reflect.apply(target, thisArg, args);
78
+ },
79
+ get(target, prop) {
80
+ if (prop !== "do") {
81
+ return Reflect.get(target, prop);
82
+ }
83
+ return function (name, ...rest) {
84
+ const args = rest.map((arg) =>
85
+ typeof arg === "function" ? wrapWorkflowStepCallback(arg) : arg
86
+ );
87
+ return target.do(name, ...args);
88
+ };
89
+ },
90
+ });
91
+ }
@@ -149,7 +149,17 @@ async def test_step_retry_config(env):
149
149
  async def test_non_retryable_error(env):
150
150
  instance = await env.MY_WORKFLOW.create({"params": {"mode": "non_retryable"}})
151
151
  status = await _poll(instance)
152
- assert status["status"] == "errored", f"unexpected status: {dict(status)!r}"
152
+ assert status["status"] == "complete", f"unexpected status: {dict(status)!r}"
153
+ out = status["output"]
154
+ # The step would succeed on attempt 2, so `retried` means the engine ignored
155
+ # the NonRetryableError.
156
+ assert out["retried"] is False, f"step was retried: {out!r}"
157
+ # ...and the error must come back to `run()` as a Python NonRetryableError.
158
+ assert out["caught"] == "NonRetryableError", out
159
+ # The message is preserved end to end in workerd, but miniflare currently
160
+ # truncates error messages crossing from the Python worker into its
161
+ # Workflows engine at the first ": " so accept an empty message here.
162
+ assert out["message"] in ("do not retry", ""), out
153
163
 
154
164
 
155
165
  async def test_error_handling_catch(env):
@@ -109,14 +109,30 @@ class TestWorkflow(WorkflowEntrypoint):
109
109
  return await flaky()
110
110
 
111
111
  async def _non_retryable(self, event, step):
112
+ # Fails on the first attempt with NonRetryableError and would succeed on a
113
+ # second attempt. If the engine honours NonRetryableError the step fails
114
+ # once and `run()` sees a NonRetryableError; if the engine retries, the step
115
+ # completes with `attempt == 2`.
112
116
  @step.do(
113
117
  "non-retryable-step",
114
- config={"retries": {"limit": 1, "delay": 0, "backoff": "constant"}},
118
+ config={"retries": {"limit": 3, "delay": 0, "backoff": "constant"}},
115
119
  )
116
- async def boom():
117
- raise NonRetryableError("do not retry")
120
+ async def boom(ctx):
121
+ if int(ctx["attempt"]) < 2:
122
+ raise NonRetryableError("do not retry")
123
+ return {"retried": True, "attempt": int(ctx["attempt"])}
118
124
 
119
- return await boom()
125
+ try:
126
+ result = await boom()
127
+ except NonRetryableError as exc:
128
+ return {
129
+ "retried": False,
130
+ "caught": "NonRetryableError",
131
+ "message": str(exc),
132
+ }
133
+ except Exception as exc:
134
+ return {"retried": False, "caught": type(exc).__name__, "message": str(exc)}
135
+ return result
120
136
 
121
137
  async def _duplicate_step_names(self, event, step):
122
138
  # The engine disambiguates repeated step names with a counter, so two
@@ -66,14 +66,27 @@ def embed(dir: Path, root: Path, level: int = 0):
66
66
  module_path = path.absolute().relative_to(module_path_root)
67
67
  embed_path = path.absolute().relative_to(root)
68
68
  if path.suffix == ".py":
69
- modules.append(
70
- f'(name = "{module_path}", pythonModule = embed "{embed_path}")'
71
- )
69
+ module_type = "pythonModule"
70
+ elif _is_sdk_js_module(path.relative_to(dir)):
71
+ module_type = "esModule"
72
72
  else:
73
- modules.append(f'(name = "{module_path}", data = embed "{embed_path}")')
73
+ module_type = "data"
74
+ modules.append(
75
+ f'(name = "{module_path}", {module_type} = embed "{embed_path}")'
76
+ )
74
77
  return modules
75
78
 
76
79
 
80
+ def _is_sdk_js_module(path_in_vendor_dir: Path) -> bool:
81
+ """Mirror wrangler: `.js`/`.mjs` files under `python_modules/workers/` are ES modules.
82
+
83
+ Other vendored packages may ship `.js` assets that are not valid ES modules, so wrangler
84
+ only applies this rule to the SDK's own `workers/` package. Everything else stays `data`.
85
+ """
86
+ in_sdk_package = path_in_vendor_dir.parts[:1] == ("workers",)
87
+ return in_sdk_package and path_in_vendor_dir.suffix in (".js", ".mjs")
88
+
89
+
77
90
  @pytest.fixture(scope="module")
78
91
  def bundle_cache_dir(tmp_path_factory):
79
92
  yield tmp_path_factory.mktemp("bundle_cache")
@@ -0,0 +1,5 @@
1
+ [project]
2
+ name = "test"
3
+ version = "0.0.0"
4
+ requires-python = ">=3.12"
5
+ dependencies = []
@@ -0,0 +1,112 @@
1
+ // Copyright (c) 2026 Cloudflare, Inc.
2
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3
+ // https://opensource.org/licenses/Apache-2.0
4
+ import { RpcTarget } from 'cloudflare:workers';
5
+
6
+ import * as assert from 'node:assert';
7
+
8
+ // A stand-in for the Workflows engine's `WorkflowStep`. Like the real engine it runs the step
9
+ // callback over RPC, and it records the error it receives when the callback fails so the test
10
+ // can assert on what the engine would have seen.
11
+ class Context extends RpcTarget {
12
+ constructor() {
13
+ super();
14
+ this.errors = [];
15
+ this.sleeps = [];
16
+ }
17
+
18
+ async do(name, ...rest) {
19
+ // do(name, callback) or do(name, config, callback)
20
+ const callback = rest.at(-1);
21
+ try {
22
+ return await callback({
23
+ step: { name, count: 1 },
24
+ attempt: 1,
25
+ config: {},
26
+ });
27
+ } catch (e) {
28
+ this.errors.push({ step: name, name: e.name, message: e.message });
29
+ // The engine rethrows so the workflow's `run()` can handle the error.
30
+ throw e;
31
+ }
32
+ }
33
+
34
+ async sleep(name, duration) {
35
+ this.sleeps.push({ name, duration });
36
+ }
37
+ }
38
+
39
+ // The engine treats a step error as non-retryable when
40
+ // `error.name === 'NonRetryableError' || error.message.startsWith('NonRetryableError')`
41
+ // (the name is folded into the message when the error is tunneled over RPC without enhanced
42
+ // error serialization).
43
+ function isNonRetryable(e) {
44
+ return (
45
+ e.name === 'NonRetryableError' || e.message.startsWith('NonRetryableError')
46
+ );
47
+ }
48
+
49
+ function nonRetryableMessage(e) {
50
+ return e.name === 'NonRetryableError'
51
+ ? e.message
52
+ : e.message.replace(/^NonRetryableError(: )?/, '');
53
+ }
54
+
55
+ export default {
56
+ async test(ctrl, env) {
57
+ const step = new Context();
58
+ const result = await env.PythonWorkflow.run(
59
+ { payload: { foo: 'bar' } },
60
+ step
61
+ );
62
+
63
+ // --- What the engine saw -------------------------------------------------------------
64
+ const byStep = Object.fromEntries(step.errors.map((e) => [e.step, e]));
65
+ assert.deepStrictEqual(Object.keys(byStep).sort(), [
66
+ 'non_retryable',
67
+ 'non_retryable_no_message',
68
+ 'type_error',
69
+ ]);
70
+
71
+ // A Python NonRetryableError must arrive as a non-retryable JS error carrying the
72
+ // Python message, not as a generic PythonError with a traceback.
73
+ assert.ok(isNonRetryable(byStep.non_retryable), byStep.non_retryable);
74
+ assert.strictEqual(nonRetryableMessage(byStep.non_retryable), 'do not retry');
75
+ assert.ok(
76
+ isNonRetryable(byStep.non_retryable_no_message),
77
+ byStep.non_retryable_no_message
78
+ );
79
+ assert.strictEqual(
80
+ nonRetryableMessage(byStep.non_retryable_no_message),
81
+ ''
82
+ );
83
+
84
+ // Other Python exceptions are left alone: they arrive as Pyodide's PythonError with the
85
+ // traceback as the message. Depending on the compatibility date the error is serialized
86
+ // either as `{name: 'PythonError', message: '<traceback>'}` (enhanced error
87
+ // serialization) or as `{name: 'Error', message: 'PythonError: <traceback>'}`.
88
+ assert.ok(!isNonRetryable(byStep.type_error), byStep.type_error);
89
+ assert.match(
90
+ `${byStep.type_error.name}: ${byStep.type_error.message}`,
91
+ /PythonError: Traceback/
92
+ );
93
+ assert.match(byStep.type_error.message, /TypeError: intentional type error/);
94
+
95
+ // --- What the Python workflow saw once the engine rethrew ----------------------------
96
+ assert.deepStrictEqual(result.non_retryable, {
97
+ caught: 'NonRetryableError',
98
+ message: 'do not retry',
99
+ });
100
+ assert.deepStrictEqual(result.non_retryable_no_message, {
101
+ caught: 'NonRetryableError',
102
+ message: '',
103
+ });
104
+ assert.strictEqual(result.type_error.caught, 'TypeError');
105
+ assert.match(result.type_error.message, /intentional type error/);
106
+
107
+ // The wrapped `step` still behaves like the real one otherwise.
108
+ assert.deepStrictEqual(result.ok, { attempt: 1, payload: { foo: 'bar' } });
109
+ assert.strictEqual(result.slept, true);
110
+ assert.deepStrictEqual(step.sleeps, [{ name: 'nap', duration: '1 second' }]);
111
+ },
112
+ };
@@ -0,0 +1,72 @@
1
+ from workers import WorkflowEntrypoint
2
+ from workers.workflows import NonRetryableError
3
+
4
+
5
+ class TestWorkflow(WorkflowEntrypoint):
6
+ """
7
+ Exercises the error path between Python steps and the Workflows engine.
8
+
9
+ The JS side (worker.js) plays the engine and records the errors each step callback
10
+ throws; the results returned from here record what `run()` sees once the engine rethrows.
11
+ """
12
+
13
+ async def run(self, event, step):
14
+ results = {}
15
+
16
+ @step.do("non_retryable")
17
+ async def non_retryable():
18
+ raise NonRetryableError("do not retry")
19
+
20
+ try:
21
+ await non_retryable()
22
+ except NonRetryableError as e:
23
+ results["non_retryable"] = {
24
+ "caught": "NonRetryableError",
25
+ "message": str(e),
26
+ }
27
+ except Exception as e: # pragma: no cover - reported to the JS side
28
+ results["non_retryable"] = {"caught": type(e).__name__, "message": str(e)}
29
+
30
+ @step.do("non_retryable_no_message")
31
+ async def non_retryable_no_message():
32
+ raise NonRetryableError()
33
+
34
+ try:
35
+ await non_retryable_no_message()
36
+ except NonRetryableError as e:
37
+ results["non_retryable_no_message"] = {
38
+ "caught": "NonRetryableError",
39
+ "message": str(e),
40
+ }
41
+ except Exception as e: # pragma: no cover - reported to the JS side
42
+ results["non_retryable_no_message"] = {
43
+ "caught": type(e).__name__,
44
+ "message": str(e),
45
+ }
46
+
47
+ # Ordinary Python exceptions are not translated: they reach the engine as a
48
+ # PythonError and come back with their type recovered from the traceback.
49
+ @step.do("type_error")
50
+ async def type_error():
51
+ raise TypeError("intentional type error")
52
+
53
+ try:
54
+ await type_error()
55
+ except TypeError as e:
56
+ results["type_error"] = {"caught": "TypeError", "message": str(e)}
57
+ except Exception as e: # pragma: no cover - reported to the JS side
58
+ results["type_error"] = {"caught": type(e).__name__, "message": str(e)}
59
+
60
+ # A successful step still works through the wrapped `step`, including receiving
61
+ # the step context and the workflow event.
62
+ @step.do("ok")
63
+ async def ok(ctx):
64
+ return {"attempt": ctx["attempt"], "payload": event["payload"]}
65
+
66
+ results["ok"] = await ok()
67
+
68
+ # Steps using the other `step` methods are forwarded to the engine untouched.
69
+ await step.sleep("nap", "1 second")
70
+ results["slept"] = True
71
+
72
+ return results
@@ -0,0 +1,30 @@
1
+ using Workerd = import "/workerd/workerd.capnp";
2
+
3
+ const config :Workerd.Config = (
4
+ services = [
5
+ (name = "py", worker = .pyWorker),
6
+ (name = "js", worker = .jsWorker),
7
+ ],
8
+ );
9
+
10
+ const pyWorker :Workerd.Worker = (
11
+ modules = [
12
+ (name = "worker.py", pythonModule = embed "worker.py"),
13
+ %PYTHON_MODULES
14
+ ],
15
+ compatibilityDate = "%COMPAT_DATE",
16
+ compatibilityFlags = ["python_workers", "python_workflows", "python_workflows_implicit_dependencies"],
17
+ );
18
+
19
+ # Stands in for the Workflows engine: calls the Python WorkflowEntrypoint over RPC and hands it
20
+ # a `step` RpcTarget, exactly like the real engine does.
21
+ const jsWorker :Workerd.Worker = (
22
+ compatibilityFlags = ["nodejs_compat"],
23
+ compatibilityDate = "%COMPAT_DATE",
24
+ modules = [
25
+ (name = "worker", esModule = embed "worker.js"),
26
+ ],
27
+ bindings = [
28
+ (name = "PythonWorkflow", service = (name = "py", entrypoint = "TestWorkflow")),
29
+ ],
30
+ );
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "test-worker",
3
+ "compatibility_date": "%COMPAT_DATE",
4
+ "compatibility_flags": ["python_workers", "python_workflows", "python_workflows_implicit_dependencies"]
5
+ }
@@ -365,7 +365,7 @@ wheels = [
365
365
 
366
366
  [[package]]
367
367
  name = "workers-runtime-sdk"
368
- version = "1.8.6"
368
+ version = "1.9.0"
369
369
  source = { editable = "." }
370
370
 
371
371
  [package.dev-dependencies]