Commit fce1a0bf authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Reland "Update TransformStream to fix transform algo error behaviour"

This is a reland of 65774ae7

The first failure to land was caused by https://crbug.com/866392
(incremental builds containing changes to V8 extras streams code
fail).
The only workaround at the moment is to retry until none of the bots
reject it.

Original change's description:
> Update TransformStream to fix transform algo error behaviour
>
> Update TransformStream to standard version
> 78cfd1e22b717ce7e6d3aae4e36de0ef9101356e. This includes change
> https://github.com/whatwg/streams/pull/948 which corrects the behaviour when the
> transformAlgorithm rejects.
>
> Also enable test TransformStreamTest.ThrowFromTransform which was disabled
> pending this fix.
>
> BUG=845427
>
> Change-Id: If0eff40c5855bf662098eecc87e32256b97dc71e
> Reviewed-on: https://chromium-review.googlesource.com/1167011
> Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
> Commit-Queue: Adam Rice <ricea@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#586601}

TBR=yhirano@chromium.org

Bug: 845427
Change-Id: Icfc128e3ae34d11d6543e529c3da5b1b075bcc0b
Reviewed-on: https://chromium-review.googlesource.com/1194543Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587021}
parent cb62ee4a
......@@ -311,14 +311,8 @@
if (typeof transformMethod !== 'function') {
throw new TypeError('transformer.transform is not a function');
}
transformAlgorithm = chunk => {
const transformPromise =
PromiseCall2(transformMethod, transformer, chunk, controller);
return thenPromise(transformPromise, undefined, e => {
TransformStreamError(stream, e);
throw e;
});
};
transformAlgorithm = chunk =>
PromiseCall2(transformMethod, transformer, chunk, controller);
} else {
transformAlgorithm = chunk => {
try {
......@@ -369,6 +363,14 @@
TransformStreamError(controller[_controlledTransformStream], e);
}
function TransformStreamDefaultControllerPerformTransform(controller, chunk) {
const transformPromise = controller[_transformAlgorithm](chunk, controller);
return thenPromise(transformPromise, undefined, r => {
TransformStreamError(controller[_controlledTransformStream], r);
throw r;
});
}
function TransformStreamDefaultControllerTerminate(controller) {
const stream = controller[_controlledTransformStream];
const readableController =
......@@ -404,11 +406,12 @@
// assert(binding.isWritableStreamWritable(writable),
// `state is "writable"`);
return controller[_transformAlgorithm](chunk, controller);
return TransformStreamDefaultControllerPerformTransform(controller,
chunk);
});
}
return controller[_transformAlgorithm](chunk, controller);
return TransformStreamDefaultControllerPerformTransform(controller, chunk);
}
function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
......
......@@ -366,9 +366,7 @@ TEST_F(TransformStreamTest, EnqueueFromFlush) {
EXPECT_TRUE(chunkSeen);
}
// TODO(ricea): Re-enable this test when throwing from Transform() works
// properly. See https://github.com/whatwg/streams/issues/946.
TEST_F(TransformStreamTest, DISABLED_ThrowFromTransform) {
TEST_F(TransformStreamTest, ThrowFromTransform) {
static constexpr char kMessage[] = "errorInTransform";
class ThrowFromTransformTransformer : public TransformStreamTransformer {
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment