Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,54 @@ void setupReferenceTests() {
expect(complete.metadata?.contentType, 'image/jpeg');
},
);

// Overlapping putData calls previously native-crashed Windows by
// sending task events off the platform thread. Sequential putData
// tests do not hit that path.
// See https://github.com/firebase/flutterfire/issues/18664.
test(
'uploads many small files concurrently and reads them back',
() async {
final bytes = Uint8List.fromList(
utf8.encode(
jsonEncode({
'id': List.generate(300, (i) => i),
'label': List.generate(300, (i) => 'Synthetic customer $i'),
}),
),
);
const rounds = 3;
const uploadsPerRound = 13;
final prefix =
'flutter-tests/concurrent-put-data/${DateTime.now().microsecondsSinceEpoch}';

for (var round = 0; round < rounds; round++) {
final refs = List<Reference>.generate(
uploadsPerRound,
(i) => storage.ref('$prefix/round-$round-$i.json'),
);

final snapshots = await Future.wait(
refs.map(
(ref) => ref.putData(
bytes,
SettableMetadata(contentType: 'application/json'),
),
),
);

expect(snapshots, hasLength(uploadsPerRound));
for (final snapshot in snapshots) {
expect(snapshot.state, TaskState.success);
}

for (final ref in refs) {
expect(await ref.getData(), bytes);
}
}
},
timeout: const Timeout(Duration(minutes: 2)),
);
},
);

Expand Down
Loading
Loading