Running HttpServer example from documentation leads to weirdness and VM issues #7356
Labels
area-vm
Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
closed-obsolete
Closed as the reported issue is no longer relevant
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
This issue was originally filed by jjinux...@google.com
I went (http://www.dartlang.org/articles/io/) to get this example:
import 'dart:io';
_send404(HttpResponse response) {
response.statusCode = HttpStatus.NOT_FOUND;
response.outputStream.close();
}
startServer(String basePath) {
var server = new HttpServer();
server.listen('127.0.0.1', 8080);
server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
final String path = request.path == '/' ? '/index.html' : request.path;
final File file = new File('${basePath}${path}');
file.exists().then((bool found) {
if (found) {
file.fullPath().then((String fullPath) {
if (!fullPath.startsWith(basePath)) {
_send404(response);
} else {
file.openInputStream().pipe(response.outputStream);
}
});
} else {
_send404(response);
}
});
};
}
main() {
// Compute base path for the request based on the location of the
// script and then start the server.
File script = new File(new Options().script);
script.directory().then((Directory d) {
startServer(d.path);
});
}
When I run the code, it looks like it's working, but it doesn't actually listen on port 8080. It seems to just do nothing. When I try to set a breakpoint on the first line of the startServer function, the server output says:
dart --enable-checked-mode bin/server.dart
./vm/object.h:3146: error: Handle check failed: saw Function 'StackOverflowError.': constructor const. expected Instance
The text was updated successfully, but these errors were encountered: