Permalink
Browse files

* Handle OPTIONS and webworker thread errors

  • Loading branch information...
1 parent 6e82fb5 commit 5da9a99d2cc4c7edcb68541f17c3cd8e1ae01682 @audreyt committed Mar 25, 2013
Showing with 10 additions and 2 deletions.
  1. +4 −1 main.js
  2. +3 −0 sc.js
  3. +2 −1 src/main.ls
  4. +1 −0 src/sc.ls
View
@@ -34,9 +34,12 @@
};
if (this.CORS) {
console.log("Cross-Origin Resource Sharing (CORS) enabled.");
- this.all('*', function(arg$, arg1$, next){
+ this.all('*', function(req, res, next){
this.response.header('Access-Control-Allow-Origin', '*');
this.response.header('Access-Control-Allow-Headers', 'X-Requested-With');
+ if ((req != null ? req.method : void 8) === 'OPTIONS') {
+ return res.send(204);
+ }
return next();
});
}
View
3 sc.js
@@ -350,6 +350,9 @@
return console.log("==> Regenerated snapshot for " + room);
});
};
+ w.onerror = function(it){
+ return console.log(it);
+ };
w.onmessage = function(arg$){
var ref$, type, snapshot, html, csv, ref, parts, save;
ref$ = arg$.data, type = ref$.type, snapshot = ref$.snapshot, html = ref$.html, csv = ref$.csv, ref = ref$.ref, parts = ref$.parts, save = ref$.save;
View
@@ -33,9 +33,10 @@
if @CORS
console.log "Cross-Origin Resource Sharing (CORS) enabled."
- @all \* (,, next) ->
+ @all \* (req, res, next) ->
@response.header \Access-Control-Allow-Origin \*
@response.header \Access-Control-Allow-Headers \X-Requested-With
+ return res.send(204) if req?method is \OPTIONS
next!
@get '/': sendFile \index.html
View
@@ -148,6 +148,7 @@ catch => console.log "Falling back to vm.CreateContext backend"; class => (code)
.bgsave!
.exec!
console.log "==> Regenerated snapshot for #room"
+ w.onerror = -> console.log it
w.onmessage = ({ data: { type, snapshot, html, csv, ref, parts, save } }) -> switch type
| \snapshot => w.on-snapshot snapshot
| \save => w.on-save save

0 comments on commit 5da9a99

Please sign in to comment.