#255 Errors thrown during server-started event are not caught

Reporter MattJ
Owner MattJ
Created
Updated
Stars ★ (1)  
Tags
  • Priority-Medium
  • Usability
  • Type-Defect
  • Status-Accepted
  1. MattJ on

    *What steps will reproduce the problem?* 1. bosh_ports = 1234 in current trunk. *What is the expected output? What do you see instead?* An error should at least be logged. Today Prosody dies silently (well, Lua prints out a stack trace to stdout, but this is not seen if the process has daemonized).

  2. Zash on

    diff -r 4fc6b0a090bb prosody --- a/prosody Wed Aug 26 13:17:37 2015 +0200 +++ b/prosody Wed Aug 26 15:45:09 2015 +0200 @@ -355,7 +355,6 @@ function init_global_protection() prosody.lock_globals(); end -function loop() -- Error handler for errors that make it this far local function catch_uncaught_error(err) if type(err) == "string" and err:match("interrupted!$") then @@ -371,6 +370,7 @@ function loop() prosody.events.fire_event("very-bad-error", {error = err, traceback = traceback}); end +function loop() while select(2, xpcall(server.loop, catch_uncaught_error)) ~= "quitting" do socket.sleep(0.2); end @@ -381,6 +381,7 @@ function cleanup() prosody.events.fire_event("server-cleanup"); end +function startup() -- Are you ready? :) -- These actions are in a strict order, as many depend on -- previous steps to have already been performed @@ -402,10 +403,13 @@ prepare_to_start(); prosody.events.fire_event("server-started"); +error("Kaboom!"); -- XXX for testing, remove before committing loop(); log("info", "Shutting down..."); cleanup(); prosody.events.fire_event("server-stopped"); log("info", "Shutdown complete"); +end +xpcall(startup, catch_uncaught_error);

New comment