Open bsutton opened 3 years ago
I've done some more digging. It does look to be a bug in http_impl.dart
on line 1736:
if (chunk.length > _buffer!.length - _length) {
The variable _buffer is null and you can see in the _addChunk method there is no test for a non-null _buffer.
I should note that this error is preceded by a number of other exceptions in the http lib but I"m uncertain if they are related.
For the record the errors are related to:
http_headers.dart:
void _build(BytesBuilder builder) {
_headers.forEach((String name, List<String> values) {
String originalName = _originalHeaderName(name);
bool fold = _foldHeader(name);
var nameData = originalName.codeUnits;
builder.add(nameData);
builder.addByte(_CharCode.COLON);
builder.addByte(_CharCode.SP);
for (int i = 0; i < values.length; i++) {
if (i > 0) {
if (fold) {
builder.addByte(_CharCode.COMMA);
builder.addByte(_CharCode.SP);
} else {
builder.addByte(_CharCode.CR);
builder.addByte(_CharCode.LF);
builder.add(nameData);
builder.addByte(_CharCode.COLON);
builder.addByte(_CharCode.SP);
}
}
builder.add(values[i].codeUnits); # cause error as values[0] is null
}
builder.addByte(_CharCode.CR);
builder.addByte(_CharCode.LF);
});
}
line 527 results in:
Exception has occurred.
NoSuchMethodError (NoSuchMethodError: The getter 'codeUnits' was called on null.
Receiver: null
Tried calling: codeUnits)
I had to reverting to dart 2.8.4 to get around this problem.
After some additional testing I found a bug in my code that set the mimeType to null, which then resulted in the above error.
The above is still a bug as we shouldn't be seeing nnbd errors just because the mimeType wasn't set. Feels like the code doesn't deal with some error paths.
I'm getting the following stack trace :
I've tried with dart 2.10.4 and dart and 2.12.0-133.2.beta
From the error I assume this is a bug related to the nnbd implementation in the http_impl package.
Running pub upgrade I see:
I'm a little confused by the error as it looks like the http package hasn't been converted to nnbd and it looks like none of the libraries are using nnbd.