wvlet / airframe

Essential Building Blocks for Scala
https://wvlet.org/airframe
Apache License 2.0
631 stars 65 forks source link

airspec: org.scalajs.testing.adapter.JSEnvRPC$RunTerminatedException #2893

Closed xerial closed 1 year ago

xerial commented 1 year ago

airspec runner occasionally fails even for a simple spec.

Example failure: https://github.com/wvlet/airframe/runs/13077205895

Probably related to https://github.com/scala-js/scala-js/issues/4317

Related code

More errors:

JSRPCClientTest:
 - Create an Async RPCClient
2023-04-27T18:56:31.482Z  info [JSRPCClientTest] TestResponse(https://httpbin.org/post,HashMap(Referer -> http://localhost/, Origin -> http://localhost, Content-Length -> 22, Accept -> */*, Content-Type -> application/json;charset=utf-8, Accept-Language -> en, Accept-Encoding -> gzip, deflate, X-Amzn-Trace-Id -> Root=1-644ac55f-38a2e7e96dc81fc95c60adc0, User-Agent -> Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/20.0.0, Host -> httpbin.org))  - (JSRPCClientTest.scala:41)
     - rpc 305.19ms
java.lang.IllegalStateException: Promise already completed.
java.lang.IllegalStateException: Promise already completed.
    at $f_s_concurrent_Promise__complete__s_util_Try__s_concurrent_Promise (file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:15837:45)
    at $f_s_concurrent_Promise__failure__jl_Throwable__s_concurrent_Promise (file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:15846:10)
    at $c_Lwvlet_airframe_http_client_JSHttpClientChannel.wvlet$airframe$http$client$JSHttpClientChannel$$$anonfun$sendAsync$2__Lorg_scalajs_dom_Event__s_concurrent_Promise__Lwvlet_airframe_http_HttpMessage$Request__s_concurrent_Promise (file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:107233:10)
    at XMLHttpRequest.$c_Lwvlet_airframe_http_client_JSHttpClientChannel.sendAsync__Lwvlet_airframe_http_HttpMessage$Request__Lwvlet_airframe_http_ChannelConfig__Lwvlet_airframe_rx_Rx.xhr.onerror (file:///Users/leo/work/git/airframe/airframe-http/.js/target/scala-2.13/airframe-http-test-fastopt/main.js:107215:35)
    at XMLHttpRequest.invokeTheCallbackFunction (/Users/leo/work/git/airframe/node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js:14:28)
    at XMLHttpRequest.<anonymous> (/Users/leo/work/git/airframe/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:35:32)
    at innerInvokeEventListeners (/Users/leo/work/git/airframe/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)
    at invokeEventListeners (/Users/leo/work/git/airframe/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)
    at XMLHttpRequestImpl._dispatch (/Users/leo/work/git/airframe/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9)
    at fireAnEvent (/Users/leo/work/git/airframe/node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36)
[error] stack trace is suppressed; run last httpJS / Test / executeTests for the full output
xerial commented 1 year ago

Probably fixed by #2894

xerial commented 1 year ago

Still see this error https://github.com/wvlet/airframe/runs/13080609348

xerial commented 1 year ago

I hope this fix will catch such an exception #2895

xerial commented 1 year ago

The exception is happening at the sbt test runner, so AirSpec can't fix this. An example error #2905

Fixed by using a different free REST service for Scala.js #2906