Permalink
Browse files

payload can accept a querystring

If using a webhook, the payload is a querystring (at least with twilio), which JSON cannot parse.  This causes the script to fail with a Syntax Error.

Added try/catch block to retry with querystring.
  • Loading branch information...
dusty committed Jul 19, 2014
1 parent 2247549 commit d43f2a24c8ee49803f79b062782e9b12afe0c32f
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/iron_worker_ng/code/runtime/node.rb
@@ -10,13 +10,18 @@ def runtime_bundle(container, local = false)
/* #{IronWorkerNG.full_version} */
var fs = require('fs');
+var querystring = require('querystring');
var params = null;
var task_id = null;
var config = null;
process.argv.forEach(function(val, index, array) {
if (val == "-payload") {
- params = JSON.parse(fs.readFileSync(process.argv[index + 1], 'utf8'));
+ try {
+ params = JSON.parse(fs.readFileSync(process.argv[index + 1], 'utf8'));
+ } catch(e) {
+ params = querystring.parse(fs.readFileSync(process.argv[index + 1], 'utf8'))
+ }
}
if (val == "-config") {

0 comments on commit d43f2a2

Please sign in to comment.