Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Bad state: StreamSink is closed

$
0
0

I'm new to Dart and tried write some test web server.
Don't see any problem here, just looked into docs and it's like the same.
Will be very thanks if someone knows how to fix that problem.

main

import 'dart:io';import 'modules/TestModule.dart';Future main() async {  var server = await HttpServer.bind(    InternetAddress.loopbackIPv4,    1337,  );  print('Listening on localhost:${server.port}');  await for (HttpRequest request in server) {     switch (request.uri.path) {      case "/test":        await testHandler(request);      break;      default:    }  }}

TestModule

import 'dart:io';Future<void> testHandler(HttpRequest req) async {  await req.response  ..write("hello")  ..close();}

Log

Bad state: StreamSink is closed#0      _StreamSinkImpl.add (dart:_http/http_impl.dart:599:7)#1      _HttpOutboundMessage.add (dart:_http/http_impl.dart:820:11)#2      _IOSinkImpl.write (dart:_http/http_impl.dart:734:5)#3      _HttpOutboundMessage.write (dart:_http/http_impl.dart:828:11)#4      testHandler (file:///root/dart_prog/modules/TestModule.dart:3:5)<asynchronous suspension>#5      main (file:///root/dart_prog/main.dart:15:15)<asynchronous suspension>#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Happens on

await req.response  ..write("hello")  ..close();

when trying to load page.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>