Skip to content

Commit 9f32c61

Browse files
authored
fix(functions, web): dartify results from cloud function stream (#18212)
* fix(functions, web): dartify results from cloud function stream * fix test * chore: use _dartify to process results from cloud function stream
1 parent 7e0a222 commit 9f32c61

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

packages/cloud_functions/cloud_functions_web/lib/interop/functions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class HttpsCallable extends JsObjectWrapper<JSFunction> {
103103
}
104104

105105
final result = await streamResult.data.toDart;
106-
yield {'result': result};
106+
yield {'result': _dartify(result)};
107107
}
108108
}
109109

tests/integration_test/cloud_functions/cloud_functions_e2e_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,24 @@ void main() {
397397
);
398398
});
399399

400+
test(
401+
'Result.data is Map<String, dynamic> for object-shaped JSON',
402+
() async {
403+
final stream = callable.stream({
404+
'type': 'deepMap',
405+
'inputData': data.deepMap,
406+
});
407+
final terminalEvent = await stream.where((e) => e is Result).last;
408+
expect(terminalEvent, isA<Result>());
409+
final result = (terminalEvent as Result).result;
410+
expect(
411+
result.data,
412+
isA<Map<String, dynamic>>(),
413+
);
414+
},
415+
skip: !kIsWeb,
416+
);
417+
400418
test('accepts a [List]', () async {
401419
final stream =
402420
callable.stream(data.list).where((event) => event is Chunk);

0 commit comments

Comments
 (0)