repl: Use a domain to catch async errors safely

Fix #2031