httpsProxyAgent is not defined - node.js

I am integrating linkedin authentication with my node.js by passport-linkedin.
It works fine initially. I am redirected to login/signup page. User is entering their details but then when it is coming to authentication I get the error
InternalOAuthError: Failed to obtain access token
at Strategy.OAuth2Strategy._createOAuthError (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:379:17)
at C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:166:45
at C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:199:18
at ClientRequest.<anonymous> (C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:170:5)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
I checked on stack overflow and got to know that it is because of corporate proxy. I added
var HttpsProxyAgent = require('https-proxy-agent');
if (process.env['https_proxy']) {
httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy']);
}
and
options.agent = httpsProxyAgent;
in oauth2.js. But now I am getting this error
ReferenceError: httpsProxyAgent is not defined
at exports.OAuth2._request (C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:126:19)
at exports.OAuth2.getOAuthAccessToken (C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:197:8)
at loaded (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:164:20)
at NullStore.verify (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\state\null.js:9:3)
at Strategy.OAuth2Strategy.authenticate (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:210:26)
at attempt (C:\Users\SU40006113\Desktop\second\node_modules\passport\lib\middleware\authenticate.js:361:16)
at authenticate (C:\Users\SU40006113\Desktop\second\node_modules\passport\lib\middleware\authenticate.js:362:7)
at Layer.handle [as handle_request] (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:275:10)
at Function.handle (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:174:3)
at router (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:47:12)
I have installed https-proxy-agent.
What's causing the error?

Related

AdapterError: Unexpected error from database adapter: `select` failed ("badConnection")

I'm getting the following error if I run any api end point where db operation is involved in sails.js (v 1.4.0). I'm using sails-mysql (v 1.0.1).
For your information, it is producing this error in aws ec2 ubuntu 18. My node version 13/14.
I'm not getting any error in my development environment.
error: Sending 500 ("Server Error") response:
AdapterError: Unexpected error from database adapter: `select` failed ("badConnection"). A connection either could not be obtained or there was an error using the connection.
Additional data:
{
error: Error: getaddrinfo EAI_AGAIN abmaster
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
--------------------
at Protocol._enqueue (/var/www/html/api/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/var/www/html/api/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at PoolConnection.connect (/var/www/html/api/node_modules/mysql/lib/Connection.js:130:18)
at Pool.getConnection (/var/www/html/api/node_modules/mysql/lib/Pool.js:48:16)
at Object.getConnection (/var/www/html/api/node_modules/machinepack-mysql/lib/get-connection.js:78:25)
at wrapper (/var/www/html/api/node_modules/#sailshq/lodash/lib/index.js:3282:19)
at Deferred.parley.retry [as _handleExec] (/var/www/html/api/node_modules/machine/lib/private/help-build-machine.js:1076:19)
at Deferred.exec (/var/www/html/api/node_modules/parley/lib/private/Deferred.js:286:10)
at Deferred.switch (/var/www/html/api/node_modules/machine/lib/private/help-build-machine.js:1469:16)
at spawnConnection (/var/www/html/api/node_modules/sails-mysql/helpers/private/connection/spawn-connection.js:29:10)
at Object.spawnOrLeaseConnection (/var/www/html/api/node_modules/sails-mysql/helpers/private/connection/spawn-or-lease-connection.js:23:3)
at Object.select (/var/www/html/api/node_modules/sails-mysql/helpers/select.js:122:24)
at wrapper (/var/www/html/api/node_modules/#sailshq/lodash/lib/index.js:3282:19)
at Deferred.parley.retry [as _handleExec] (/var/www/html/api/node_modules/machine/lib/private/help-build-machine.js:1076:19)
at Deferred.exec (/var/www/html/api/node_modules/parley/lib/private/Deferred.js:286:10)
at Deferred.switch (/var/www/html/api/node_modules/machine/lib/private/help-build-machine.js:1469:16)
at Object.find (/var/www/html/api/node_modules/sails-mysql/lib/adapter.js:185:16)
at _getPopulatedRecords (/var/www/html/api/node_modules/waterline/lib/waterline/utils/query/help-find.js:145:21)
at helpFind (/var/www/html/api/node_modules/waterline/lib/waterline/utils/query/help-find.js:582:6)
at _afterPotentiallyRunningBeforeLC (/var/www/html/api/node_modules/waterline/lib/waterline/methods/find-one.js:265:9)
at _maybeRunBeforeLC (/var/www/html/api/node_modules/waterline/lib/waterline/methods/find-one.js:239:16)
at Deferred._.extend._WLModel [as _handleExec] (/var/www/html/api/node_modules/waterline/lib/waterline/methods/find-one.js:241:9)
at Deferred.exec (/var/www/html/api/node_modules/parley/lib/private/Deferred.js:286:10)
at Object.findOneRecord (/var/www/html/api/node_modules/sails/lib/hooks/blueprints/actions/findOne.js:37:4)
at /var/www/html/api/node_modules/sails/lib/router/bind.js:248:46
at routeTargetFnWrapper (/var/www/html/api/node_modules/sails/lib/router/bind.js:395:9)
at /var/www/html/api/node_modules/sails/lib/router/bind.js:458:14
at Layer.handle [as handle_request] (/var/www/html/api/node_modules/express/lib/router/layer.js:95:5) {
errno: -3001,
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'abmaster',
fatal: true
},
meta: {
host: 'test.anonderbazar.com',
port: 3306,
schema: true,
adapter: 'sails-mysql',
url: 'mysql://abmaster:duY$1L#8rwof#test.anonderbazar.com:3306/anonderbazaar',
connectTimeout: 20000,
identity: 'default'
}
}
at Object.findOneRecord (/var/www/html/api/node_modules/sails/lib/hooks/blueprints/actions/findOne.js:36:4)
at /var/www/html/api/node_modules/sails/lib/router/bind.js:248:46
at routeTargetFnWrapper (/var/www/html/api/node_modules/sails/lib/router/bind.js:395:9)
at /var/www/html/api/node_modules/sails/lib/router/bind.js:458:14
at Layer.handle [as handle_request] (/var/www/html/api/node_modules/express/lib/router/layer.js:95:5)
at next (/var/www/html/api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/var/www/html/api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/www/html/api/node_modules/express/lib/router/layer.js:95:5)
at /var/www/html/api/node_modules/express/lib/router/index.js:281:22
at param (/var/www/html/api/node_modules/express/lib/router/index.js:354:14)
at param (/var/www/html/api/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/var/www/html/api/node_modules/express/lib/router/index.js:410:3)
at next (/var/www/html/api/node_modules/express/lib/router/index.js:275:10)
at next (/var/www/html/api/node_modules/express/lib/router/route.js:127:14)
at alwaysAllow (/var/www/html/api/node_modules/sails/lib/hooks/policies/index.js:178:16)
at routeTargetFnWrapper (/var/www/html/api/node_modules/sails/lib/router/bind.js:395:9)
at /var/www/html/api/node_modules/sails/lib/router/bind.js:458:14
at Layer.handle [as handle_request] (/var/www/html/api/node_modules/express/lib/router/layer.js:95:5)
at next (/var/www/html/api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/var/www/html/api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/www/html/api/node_modules/express/lib/router/layer.js:95:5)
at /var/www/html/api/node_modules/express/lib/router/index.js:281:22
at param (/var/www/html/api/node_modules/express/lib/router/index.js:354:14)
at param (/var/www/html/api/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/var/www/html/api/node_modules/express/lib/router/index.js:410:3)
at next (/var/www/html/api/node_modules/express/lib/router/index.js:275:10)
at next (/var/www/html/api/node_modules/express/lib/router/route.js:127:14)
at Hook.expressMiddleware (/var/www/html/api/node_modules/sails/lib/hooks/i18n/index.js:205:14)
Any kind of help from anyone will be much appreciated.
I had this problem, my problem was that the password of my user had an '#' and in the connection there was also one, change the password and solve the error

mysql2 connection.connect() hangs in typescript jest test on macOS

I am trying to create a mysql2 connection to a local mysql-Database in a jest-Test on macOS using typescript. And the call to connect() hangs.
Environment:
MacOS: High Sierra (10.13.6)
MySQL: 8.0.18
Typescript: 3.7.2
mysql2: 2.0.1
nodejs: v10.16.3
I am using the promise-Wrapper. The code looks like this:
import { createConnection, ConnectionOptions, Connection } from 'mysql2/promise'
...
async openConnection(options: ConnectionOptions): Promise<Connection> {
console.log('About to create mysql connection using options ', options);
const connection = await createConnection(options);
console.log('Connection created => about to call connect()');
await connection.connect();
console.log('Connection created => connect() returned'); // this line is never reached!
....
return connection;
}
I already added the debug-Option and this is the output:
Dieters-MBP-6:db-typescript rehdie$ node_modules/.bin/jest src/tests/mysql/mysql-connection.spec.ts --testNamePattern="Should open connection"
console.log src/lib/mysql/driver/mysql-driver.ts:21
About to create mysql connection using options { user: 'mysql-test',
password: '1q2w3e4r',
host: 'localhost',
port: 3306,
database: 'mysql_test_db',
charset: 'latin1_swedish_ci',
connectTimeout: 5000,
debug: true }
console.log node_modules/mysql2/lib/connection.js:425
Add command: ClientHandshake
console.log node_modules/mysql2/lib/connection.js:381
raw: 0a382e302e31380018000000277919626469296e00ffffff0200ffc715000000000000000000006d6335316a3c3d454220053a0063616368696e675f736861325f70617373776f726400
console.error console.js:274
Trace:
at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
console.log node_modules/mysql2/lib/connection.js:395
0 undefined ==> ClientHandshake#unknown name(0,,78)
console.log node_modules/mysql2/lib/commands/client_handshake.js:96
Server hello packet: capability flags:3355443199=(long password, found rows, long flag, connect with db, no schema, compress, odbc, local files, ignore space, protocol 41, interactive, ssl, ignore sigpipe, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, connect attrs, plugin auth lenenc client data, can handle expired passwords, session track, deprecate eof, ssl verify server cert, remember options)
console.log node_modules/mysql2/lib/commands/client_handshake.js:41
Sending handshake packet: flags:11203535=(long password, found rows, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, plugin auth, plugin auth lenenc client data, session track)
console.log node_modules/mysql2/lib/connection.js:253
0 24 <== ClientHandshake#unknown name(1,,104)
console.log node_modules/mysql2/lib/connection.js:257
0 24 <== 64000001cff3aa00000000000800000000000000000000000000000000000000000000006d7973716c2d746573740014a13dd11599725225bcae39464cc3700a5fa085fc6d7973716c5f746573745f6462006d7973716c5f6e61746976655f70617373776f726400
console.log node_modules/mysql2/lib/connection.js:381
raw: fe63616368696e675f736861325f70617373776f726400277919626469296e6d6335316a3c3d454220053a00
console.error console.js:274
Trace:
at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
console.log node_modules/mysql2/lib/connection.js:395
0 24 ==> ClientHandshake#unknown name(2,,48)
console.log node_modules/mysql2/lib/connection.js:253
0 24 <== ClientHandshake#unknown name(3,,36)
console.log node_modules/mysql2/lib/connection.js:257
0 24 <== 20000003374930d53dd94bc2dbe6b54e4b83cd628658a1984656eb6ee4f31d7df596ce36
console.log node_modules/mysql2/lib/connection.js:381
raw: 0103
console.error console.js:274
Trace:
at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
console.log node_modules/mysql2/lib/connection.js:395
0 24 ==> ClientHandshake#unknown name(4,,6)
console.log node_modules/mysql2/lib/connection.js:381
raw: 000000024000000010010e0d6d7973716c5f746573745f6462
console.error console.js:274
Trace:
at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
console.log node_modules/mysql2/lib/connection.js:395
0 24 ==> ClientHandshake#unknown name(5,maybeOK,29)
console.log src/lib/mysql/driver/mysql-driver.ts:24
Connection created => about to call connect()
RUNS src/tests/mysql/mysql-connection.spec.ts
When I perform a show process list in mysql, I see a new process with Command 'Sleep' (state is empty and info is null).
Any ideas?
You need to ensure that node is using the system time and not fake timers. Add the below line immediately after your imports in the test file
jest.useRealTimers();
Or better still you can set timers to real in your jest config
"timers":"real"

Node app not sending any data while login 'ER_NO_DEFAULT_FOR_FIELD',

I am transferring a node app from one server to another using different domain name.
I have setup everything but I cannot login to the control panel of the app which I have created, I am getting the following error.
{ Error: ER_NO_DEFAULT_FOR_FIELD: Field 'origin' doesn't have a default value
at Query.Sequence._packetToError (/var/www/node/node_modules/mysql/lib/pro tocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/var/www/node/node_modules/mysql/lib/protocol/sequen ces/Query.js:77:18)
at Protocol._parsePacket (/var/www/node/node_modules/mysql/lib/protocol/Pr otocol.js:278:23)
at Parser.write (/var/www/node/node_modules/mysql/lib/protocol/Parser.js:7 6:12)
at Protocol.write (/var/www/node/node_modules/mysql/lib/protocol/Protocol. js:38:16)
at Socket.<anonymous> (/var/www/node/node_modules/mysql/lib/Connection.js: 91:28)
at Socket.<anonymous> (/var/www/node/node_modules/mysql/lib/Connection.js: 502:10)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
--------------------
at Protocol._enqueue (/var/www/node/anode_modules/mysql/lib/protocol/Protoc ol.js:144:48)
at Connection.query (/var/www/node/node_modules/mysql/lib/Connection.js:20 0:25)
at Object.managerLogin (/var/www/node/node_modules/login/index.js:58:15)
at callbackFunction (/var/www/node/routes/index.js:62:16)
at Layer.handle [as handle_request] (/var/www/node/node_modules/express/lib/router/ layer.js:95:5)
at next (/var/www/node/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/www/node/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/www/node/node_modules/express/lib/router/ layer.js:95:5)
at /var/www/node/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/www/node/node_modules/express/lib/router/index.js: 330:12)
at next (/var/www/node/node_modules/express/lib/router/index.js:271:10)
at /var/www/node/app.js:55:7
at Layer.handle [as handle_request] (/var/www/node/node_modules/express/lib/router/ layer.js:95:5)
at trim_prefix (/var/www/node/node_modules/express/lib/router/index.js:312:13)
at /var/www/node/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/var/www/node/node_modules/express/lib/router/index.js: 330:12)
code: 'ER_NO_DEFAULT_FOR_FIELD',
errno: 1364,
sqlMessage: 'Field \'origin\' doesn\'t have a default value',
sqlState: 'HY000',
index: 0,
sql:
'INSERT INTO userLog SET userId = 2, token = \'9d99a1a0-7350-11e9-9671-95abec1f75f6\', ip = \'\', browser = \'\', isLog = \'y\', isValid = \'y\'' }
Cannot figure this out what is happening,app was running file in the old server.
Debugged it, found it's a mysql bug, edited etc/mysql/my.cnf with [mysqld]
port = 3306
sql-mode=""
reloaded mysql, and it worked for me!

how to pass a object inside the logger.log() file in winston#3.0.0 in nodejs

i have a http request in a variable queryData = qs.parse(requestBody);
when i try to parse through winston
logger.log("info","requestbody",+queryData);
even tried
logger.log("info","requestbody %s", queryData);
logger.log("info","requestbody",{queryData});
didn't worked
am getting error like:
{ TypeError: Cannot create property 'Symbol(level)' on string 'Registering Device typeac'
at DerivedLogger.log (/home/grl/www/node_modules/winston/lib/winston/logger.js:130:20)
at createOcfRes (/home/aol/www/iot-node-server.js:285:10)
at IncomingMessage.<anonymous> (/home/aol/www/iot-node-server.js:115:9)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:186:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9) level: 'error', timestamp: '19-07-2018 20:20:19' }

Create Task in Asana Node.js

Using the below in Node trying to create a task within Workspace. I have omitted the AccessToken & WorkspaceID numbers. Suspect I'm doing something really dumb :)
var asana = require('asana');
var client = asana.Client.create().useAccessToken('0/XXXXXXXX');
var newTask = { name: "Your Mission" };
client.tasks.createInWorkspace(1111111111, newTask).then(function(response) {
tasks = response.data;
console.log(tasks);
});
At runtime I get the following output...
Unhandled rejection Error: Invalid Request
at InvalidRequest.AsanaError (/Users/D/Asana_Crons/node_modules/asana/lib/errors/error.js:4:11)
at new InvalidRequest (/Users/D/Asana_Crons/node_modules/asana/lib/errors/invalid_request.js:5:14)
at Request._callback (/Users/D/Asana_Crons/node_modules/asana/lib/dispatcher.js:152:23)
at Request.self.callback (/Users/D/Asana_Crons/node_modules/request/request.js:186:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request.<anonymous> (/Users/D/Asana_Crons/node_modules/request/request.js:1163:10)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at IncomingMessage.<anonymous> (/Users/D/Asana_Crons/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:314:30)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9)
The only issue I can see with your code is that the workspace id needs to be a string, not an integer. This is documented in the tasks section of /gen folder in the Asana Node client library.

Resources