My favorites | Sign in
Project Home Wiki Issues Source Code Search
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 7356: Running HttpServer example from documentation leads to weirdness and VM issues
2 people starred this issue and may be notified of changes. Back to list
Status:  Triaged
Owner:  ----

Sign in to add a comment
Reported by, Dec 12, 2012
I went ( to get this example:

import 'dart:io';

_send404(HttpResponse response) {
  response.statusCode = HttpStatus.NOT_FOUND;

startServer(String basePath) {
  var server = new HttpServer();
  server.listen('', 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)) {
          } else {
      } else {

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); d) {

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

Dec 12, 2012
Dart Editor version 0.2.7_r15699
Dart SDK version
Dec 12, 2012
I tried upgrading my Dart Editor, but when I click "Check for Update", it says "Unable to get latest revision". 
Dec 12, 2012
Project Member #3
I've pasted a working version of this code on stack overflow in answer to another question:

The best approach might be to start with that and add print() statements to aid debugging to add the command line arguments and 404 handler.

Jun 5, 2013
Project Member #4
(No comment was entered for this change.)
Labels: -Priority-Medium Priority-Unassigned
Sign in to add a comment

Powered by Google Project Hosting