Skip to content

js_util promiseToFuture async tests not waiting for completion on d8 #45061

Open
@rileyporter

Description

@rileyporter

When running an async test on d8 for the js_util.promiseToFuture method, the test runner seems to be completing before waiting for the async tests to finish.

Test for small repro:

import 'dart:async';

import 'package:js/js.dart';
import 'package:js/js_util.dart' as js_util;
import 'package:expect/minitest.dart';
import 'package:async_helper/async_helper.dart';

@JS()
external void eval(String code);

@JS()
abstract class Promise<T> {}

@JS()
external Promise get p;

main() {
  eval(r""" var p = new Promise(resolve => resolve('resolved'));""");

  Future<void> testResolvedPromise() async {
    final String result = await js_util.promiseToFuture(p);
    expect(result, equals('resolved'));
    print('error: never reached'); // debugging print not reached
  }

  asyncTest(() async {
    await testResolvedPromise();
  });
}

This passes on chrome configurations, but with d8 it doesn't await the resolved Promise before finishing the test. The print debugging statement is never reached before the test runner completes. Instead this error is printed:

exit code:
0

stdout:
unittest-suite-wait-for-done

Deobfuscated error and stack:
<no error message found>
    at unittest-suite-wait-for-done unparsed


--- Re-run this test:
python tools/test.py -n dart2js-production-mac-d8 tests/lib/js/js_util/async_test.dart
[00:02 | 100% | +    0 | -    1]

CL with async_test for tracking context: https://dart-review.googlesource.com/c/sdk/+/185281/2/tests/lib/js/js_util/async_test.dart The async test already existed under tests/lib/html, but was skipped for d8 configurations due to reliance on dart html.

The solution may be to update our async test to force d8 to wait manually or to figure out a way to get hooks into the Promise to know when it has completed and get d8 to listen to that signal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-infrastructureinternal techdebt or infrastructure issues affecting the web team specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions