Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

[storage] Ensure onCompletion for UploadTasks don't return anything. #345

Merged
merged 4 commits into from
Oct 14, 2020
Merged

[storage] Ensure onCompletion for UploadTasks don't return anything. #345

merged 4 commits into from
Oct 14, 2020

Conversation

ditman
Copy link
Contributor

@ditman ditman commented Oct 13, 2020

This ensures the onCompletion function created to handle UploadTasks doesn't return anything.

Testing

All tests pass, I tried to write a test for this case, but I wasn't able to pick up the exception with something like this in storage_test.dart:

test('does not throw in another zone', () async {
  final storage = app.storage();
  final subfolder = storage.ref(validDatePath()).child('sub');

  await runZonedGuarded(() async {
    final task = subfolder.putString('testing 1 2 3');
    task.pause();
    // The error only gets thrown when we listen to the status updates
    final subscription = task.onStateChanged.listen((event) => event);
    subscription.onDone(() {
      print('stream done!');
      subscription.cancel();
    });
    await Future.delayed(const Duration(seconds: 10));
    task.resume();
    await expectLater(task.future, completes);
  }, (e, s) {
    /* This NEVER happens */
    print(e);
  });

  await subfolder.delete();
});

Related issues

Fixes #343

@@ -319,6 +319,8 @@ class UploadTask extends JsObjectWrapper<storage_interop.UploadTaskJsImpl> {
});

var errorWrapper = allowInterop((e) => _changeController.addError(e));
// This seems to be a dart-lang/sdk error.
// See https://github.com/dart-lang/sdk/issues/43781
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I be nitty?

Put this code comment inside the block.

@kevmoo kevmoo merged commit b2e32cc into googlearchive:master Oct 14, 2020
@ditman ditman deleted the issue-343 branch October 14, 2020 00:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[storage] TypeError: T.as is not a function at _Future.new.[_setValue] when upload completes
2 participants