Accessing AWS native npms for fails - aws-lambda

I'm working my way through an example for AWS Transcribe right out of Amazon's documentation, but it's failing at the require, and I'm wondering what I'm missing for the setup to get this to work. The log reports Error: Cannot find module '#aws-sdk/client-transcribe' and you can see the full example and log below.
This is my first project with lambdas and node.js, but I've gotten all the other AWS Lambda code running, so I suspect this is an error on my part. I've been searching and come up empty-handed.
const {
TranscribeClient,
StartTranscriptionJobCommand,
} = require("#aws-sdk/client-transcribe");
// Set the AWS Region
const REGION = "REGION"; // For example, "us-east-1"
// Set the parameters
const params = {
TranscriptionJobName: "JOB_NAME",
LanguageCode: "LANGUAGE_CODE", // For example, 'en-US'
MediaFormat: "SOURCE_FILE_FORMAT", // For example, 'wav'
Media: {
MediaFileUri: "SOURCE_LOCATION",
// For example, "https://transcribe-demo.s3-REGION.amazonaws.com/hello_world.wav"
},
};
// Create an Amazon Transcribe service client object
const client = new TranscribeClient({ region: REGION });
const run = async () => {
try {
const data = await client.send(new StartTranscriptionJobCommand(params));
console.log("Success - put", data);
} catch (err) {
console.log("Error", err);
}
};
run();
And this is the entry in the log:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '#aws-sdk/client-transcribe'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module '#aws-sdk/client-transcribe'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}
2021-01-29T23:25:31.952Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '#aws-sdk/client-transcribe'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","stack":["Runtime.ImportModuleError: Error: Cannot find module '#aws-sdk/client-transcribe'","Require stack:","- /var/task/index.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"]}

The example that you are using imports and use AWS Service V3 package clients.
At the moment the Node.js runtimes in lambda environment include AWS SDK 2.804.0.
You must include the new version in your deployment.

Install npm, then run 'npm install' on the github repo for these examples, as per the prerequisite instructions here for these examples.
It will install all the required AWS SDK for JavaScript V3 modules required for the example. If these are missing the error you quote is triggered.

It turns out there was a way to get this same functionality without installing the AWS npms beyond whatever Amazon delivers with the base lambda instance.
const AWS = require('aws-sdk');
// Set the AWS Region
const REGION = "REGION"; // For example, "us-east-1"
// Set the parameters
const params = {
TranscriptionJobName: "JOB_NAME",
LanguageCode: "LANGUAGE_CODE", // For example, 'en-US'
MediaFormat: "SOURCE_FILE_FORMAT", // For example, 'wav'
Media: {
MediaFileUri: "SOURCE_LOCATION",
// For example, "https://transcribe-demo.s3-REGION.amazonaws.com/hello_world.wav"
},
};
// Create an Amazon Transcribe service client object
const client = new TranscribeClient({ region: REGION });
const run = async () => {
try {
transcribe.startTranscriptionJob(params, (err, data) => {
if (err) {
console.log("Success - put", data);
throw(err);
}
else
{
const data = await client.send(new StartTranscriptionJobCommand(params));
console.log("Success - put", data);
}
});
} catch (err) {
console.log("Error", err);
}
};
run();

Related

Unable to query dynamodb GSI in lambda locally

So I added a lambda function category using the amplify CLI, in order to query data from the GSI(Global secondary Index) I created using the #key directive in the graphql schema. Whenever I try mocking the function locally using the amplify mock function <functionName> the callback function of the query keeps on returning null. The function can be seen below
const AWS = require("aws-sdk");
const db = new AWS.DynamoDB.DocumentClient({
region: process.env.REGION,
apiVersion: "2012-08-10",
});
const params = {
// ProjectionExpression: ["province", "gender", "updatedAt", "createdAt"],
ExpressionAttributeValues: {
":provinceVal": "Sichuan",
},
IndexName: "RegistreesByProvince",
KeyConditionExpression: "province = :provinceVal",
TableName: process.env.API_PORTAL_SUBMISSIONSTABLE_NAME,
};
const calculateStatistics = async () => {
try {
const data = await db.query(params).promise();
console.log(data);
} catch (err) {
console.log(err);
}
};
const resolvers = {
Query: {
getStatistics: () => {
return calculateStatistics();
},
},
};
exports.handler = async (event) => {
// TODO implement
const typeHandler = resolvers[event.typeName];
if (typeHandler) {
const resolver = typeHandler[event.fieldName];
if (resolver) {
var result = await resolver(event);
return result;
}
}
}; // };
I then tried to capture the whole event and logged it to the console as can be seen in the calculateStatistics function, which now showed me a bit more explicit error as follows.
{ UnknownEndpoint: Inaccessible host: `dynamodb.us-east-1-fake.amazonaws.com'. This service may not be available in the `us-east-1-fake' region.
at Request.ENOTFOUND_ERROR (/Users/apple/Documents/work/web/portal/amplify/backend/function/calcStatistics/src/node_modules/aws-sdk/lib/event_listeners.js:501:46)
at Request.callListeners (/Users/apple/Documents/work/web/portal/amplify/backend/function/calcStatistics/src/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/apple/Documents/work/web/portal/amplify/backend/function/calcStatistics/src/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/apple/Documents/work/web/portal/amplify/backend/function/calcStatistics/src/node_modules/aws-sdk/lib/request.js:688:14)
at ClientRequest.error (/Users/apple/Documents/work/web/portal/amplify/backend/function/calcStatistics/src/node_modules/aws-sdk/lib/event_listeners.js:339:22)
at ClientRequest.<anonymous> (/Users/apple/Documents/work/web/portal/amplify/backend/function/calcStatistics/src/node_modules/aws-sdk/lib/http/node.js:96:19)
at ClientRequest.emit (events.js:198:13)
at ClientRequest.EventEmitter.emit (domain.js:448:20)
at TLSSocket.socketErrorListener (_http_client.js:401:9)
at TLSSocket.emit (events.js:198:13)
message:
'Inaccessible host: `dynamodb.us-east-1-fake.amazonaws.com\'. This service may not be available in the `us-east-1-fake\' region.',
code: 'UnknownEndpoint',
region: 'us-east-1-fake',
hostname: 'dynamodb.us-east-1-fake.amazonaws.com',
retryable: true,
originalError:
{ Error: getaddrinfo ENOTFOUND dynamodb.us-east-1-fake.amazonaws.com dynamodb.us-east-1-fake.amazonaws.com:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
message:
'getaddrinfo ENOTFOUND dynamodb.us-east-1-fake.amazonaws.com dynamodb.us-east-1-fake.amazonaws.com:443',
errno: 'ENOTFOUND',
code: 'NetworkingError',
syscall: 'getaddrinfo',
hostname: 'dynamodb.us-east-1-fake.amazonaws.com',
host: 'dynamodb.us-east-1-fake.amazonaws.com',
port: 443,
region: 'us-east-1-fake',
retryable: true,
time: 2020-08-12T10:18:08.321Z },
time: 2020-08-12T10:18:08.321Z }
Result:
null
Finished execution.
I then did more research and came across this thread about inaccessible-dynamodb-host-when-running-amplify-mock which I followed and tried implementing to but to no avail. Any help on this would be very much appreciated.
PS: It is worth mentioning that I was able to successfully query for this data through the Appsync console, which led me to strongly believe the problem lies in the function itself.
After doing more research and asking around, I finally made sense of the answer that was provided to me on github that
When running mock on a function which has access to a dynamodb
table generated by API. It will populate the env with fake values. If
you would like to mock your lambda function against your deployed
dynamodb table you can edit the values in the sdk client so it can
make the call accurately.
In summary, if you are running things locally, then you wouldn't have access to your backend variables which you might try mocking. I hope this helps someone. Thanks!

Dialogflow v2 client library not working | Error: Could not load the default credentials

here is their sample code:
const dialogflow = require('dialogflow');
const uuid = require('uuid');
/**
* Send a query to the dialogflow agent, and return the query result.
* #param {string} projectId The project to be used
*/
async function runSample(projectId = 'your-project-id') {
// A unique identifier for the given session
const sessionId = uuid.v4();
// Create a new session
const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
// The query to send to the dialogflow agent
text: 'hello',
// The language used by the client (en-US)
languageCode: 'en-US',
},
},
};
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
const result = responses[0].queryResult;
console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`);
if (result.intent) {
console.log(` Intent: ${result.intent.displayName}`);
} else {
console.log(` No intent matched.`);
}
}
and this code is not working at all, giving Error: Could not load the default credentials :
2019-03-21T16:59:40.099101+00:00 app[web.1]: Message: hi Bilal
2019-03-21T16:59:40.102561+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
2019-03-21T16:59:40.102565+00:00 app[web.1]: at GoogleAuth.<anonymous> (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:168:23)
2019-03-21T16:59:40.102568+00:00 app[web.1]: at Generator.next (<anonymous>)
2019-03-21T16:59:40.102570+00:00 app[web.1]: at fulfilled (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)
2019-03-21T16:59:40.102572+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2019-03-21T16:59:40.102691+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2019-03-21T16:59:40.102784+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2019-03-21T16:59:55.986568+00:00 app[web.1]: Message: hi Bilal
2019-03-21T16:59:55.986595+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
2019-03-21T16:59:55.986598+00:00 app[web.1]: at GoogleAuth.<anonymous> (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:168:23)
2019-03-21T16:59:55.986600+00:00 app[web.1]: at Generator.next (<anonymous>)
2019-03-21T16:59:55.986602+00:00 app[web.1]: at fulfilled (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)
2019-03-21T16:59:55.986605+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2019-03-21T16:59:55.986647+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
they have instructions how to use this library in the repo but it doesnt makes sense https://github.com/googleapis/nodejs-dialogflow
they have not described anywhere how to put credentials while calling detect intent, not eve in the example code here: https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.js
I have never seen such irresponsible team like dialogflow team in my life
Update:
exporting env variable solved my problem and now I am getting something back from dialogflow but not as expected, may be they have incorrect code in their repository sample code
this is the code they do have as try an example:
...
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
const result = responses[0].queryResult;
console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`);
if (result.intent) {
console.log(` Intent: ${result.intent.displayName}`);
} else {
console.log(` No intent matched.`);
}
...
and in fact result.fulfillmentText does not exist, it is giving me undefined
Update 2
that much effort I have done(see console.logs below) just to understand that instead of responses[0].queryResult.fulfillmentText now they return responses[0].queryResult.fulfillmentMessages and it is not a text string but it is an object which have further values in it that you can see in console.logs below:
...
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
console.log("responses: ", responses)
console.log("responses[0]: ", responses[0])
console.log("responses[0].queryResult: ", responses[0].queryResult)
console.log("responses[0].queryResult.fulfillmentMessages: ", responses[0].queryResult.fulfillmentMessages)
// console.log("responses[0].queryResult.fulfillmentMessages[1]: ", responses[0].queryResult.fulfillmentMessages[1])
console.log("responses[0].queryResult.fulfillmentMessages[0]: ", responses[0].queryResult.fulfillmentMessages[0])
console.log("responses[0].queryResult.fulfillmentMessages[0].text: ", responses[0].queryResult.fulfillmentMessages[0].text)
console.log("responses[0].queryResult.fulfillmentMessages[0].text.text: ", responses[0].queryResult.fulfillmentMessages[0].text.text)
console.log("responses[0].queryResult.fulfillmentMessages[0].text.text[0]: ", responses[0].queryResult.fulfillmentMessages[0].text.text[0])
var fulfilmentText = responses[0].queryResult.fulfillmentMessages[0].text.text[0]
...
The google auth library is looking for an environment variable called
GOOGLE_APPLICATION_CREDENTIALS that points to a JSON credentials file.
You can download that file by following instructions as described in https://dialogflow.com/docs/reference/v2-auth-setup.
The link after the error message has examples of how to set that environment variable:
https://cloud.google.com/docs/authentication/getting-started
Have you tried taking a look at this? You'll need to set up authentication, create a service account key as a .json then have Google Cloud SDK handle it.
https://dialogflow.com/docs/reference/v2-auth-setup
You can also try passing in the service account like this
// Create a new session
const sessionClient = new dialogflow.SessionsClient({keyFilename: "./service_account.json"});

How to fix AWS Device farm SDK error Unexpected key 'type' found in params

I am trying to get the list of uploads in the AWS Device Farm. I tried to use the method "devicefarm.listUploads" from Lambda.
I am facing an issue when I am trying to filter it by type.
var uploadList = devicefarm.listUploads({ arn: deviceFarmProject, type: 'IOS_APP' }).promise()
.then(res => res)
.catch(err => err);
The expectation is to get data about all the iOS apps, but getting the bellow error.
{
"message": "Unexpected key 'type' found in params",
"code": "UnexpectedParameter",
"time": "2019-05-02T15:49:35.351Z"
}
~~I'm not sure why the type isn't recognized here~~
[Edit]
The reason for this error is due to the version of the aws-sdk in AWS Lambda.
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
Node.js Runtimes
Name Identifier AWS SDK for JavaScript
Node.js 8.10
nodejs8.10
2.290.0
I created a Lambda layer with the following commands and applied it to my function through the web console.
npm init
npm install aws-sdk
mkdir nodejs
cp -r node-modules nodejs
zip -r aws-sdk-layer.zip nodejs
note the zip file structure needs to match the Lambda documentation example.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
Node.js – nodejs/node_modules, nodejs/node8/node_modules (NODE_PATH)
Example AWS X-Ray SDK for Node.js
xray-sdk.zip
└ nodejs/node_modules/aws-xray-sdk
after I applied the layer I was able to execute the function successfully.
but I used the following and it seemed to work though I didn't have any iOS uploads.
// assume we already executed `npm install aws-sdk`
var AWS = require('aws-sdk');
// Device Farm is only available in the us-west-2 region
var devicefarm = new AWS.DeviceFarm({ region: 'us-west-2' });
var params = {};
devicefarm.listProjects(params, function (err, projects) {
if (err) console.log(err, err.stack); // an error occurred
else{
project = projects.projects[0];
console.log("project: ", project);
uploadList = devicefarm.listUploads({ arn: project.arn, type: 'IOS_APP' }).promise()
.then(function(uploadList){
console.log("uploads: ",uploadList);
})
.catch(err => err);
}
});
code I executed in Lambda
// assume we already executed `npm install aws-sdk`
var AWS = require('aws-sdk');
// Device Farm is only available in the us-west-2 region
var devicefarm = new AWS.DeviceFarm({ region: 'us-west-2' });
exports.handler = async (event) => {
return new Promise(function (resolve, reject) {
var params = {};
devicefarm.listProjects(params, function (err, projects) {
if (err) reject(err); // an error occurred
else {
var project = projects.projects[0];
console.log("project: ", project);
resolve(project);
}
});
}).then(function(data){
console.log("in then function","data: ",data);
return new Promise(function(resolve,reject){
devicefarm.listUploads({ arn: data.arn, type: 'IOS_APP' }, function(err,uploads){
if (err) reject(err); // an error occurred
else {
resolve(uploads);
}
})
}).then(function(data){
console.log("uploads: ", data);
return data;
}).catch(function(data){
console.error("list uploads failed","data: ", data);
return data;
});
}).catch(function(data){
console.error("list projects failed","data: ",data);
return data;
});
};
It might be the case that the aws-sdk version in Lambda isn't up to date in which case you would need to apply a Lambda layer or include the aws-sdk in the code package.
Locally I executed this code and it provided the following output:
node sample.js
project: { arn: 'arn:aws:devicefarm:us-west-2:111122223333:project:00ec5d2a-9170-4c52-b65e-0e12986e4fc3',
name: 'web_app_test',
created: 2019-02-10T22:47:35.052Z }
uploads: { uploads: [] }
aws-sdk version: aws-sdk#2.448.0
node --version
v8.12.0
HTH
James

How to locally test a serverless lambda function?

Background
I was thrown on this project to help alleviate some stress. The trouble is no one else has done this either so I'm pioneering the cause.
What I know
I can get lambda function output locally with:
serverless invoke local -f getArticlesById -p localfile.json -s dev
and it returns a JSON article as expected.
Question
I'm using Jasmine to test my javascript lambda functions. How can I unit test these serverless environment functions locally?
Current Attempt
My lambda function is in articles/articleHandler.js. I have a test/articles.js that runs jasmine tests leveraging lambda-tester functions. Whenever I run one of these tests I get the error
TypeError: Invalid hosts config. Expected a URL, an array of urls, a host config object, or an array of host config objects.
at new Transport (/Users/Jackson/Sites/serverless-content/node_modules/elasticsearch/src/lib/transport.js:59:13)
at new EsApiClient (/Users/Jackson/Sites/serverless-content/node_modules/elasticsearch/src/lib/client.js:57:22)
at Function.Client (/Users/Jackson/Sites/serverless-content/node_modules/elasticsearch/src/lib/client.js:101:10)
at Object.<anonymous> (/Users/Jackson/Sites/serverless-content-distribution-api-v2/elasticSearch.js:6:42)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
I've found that this is caused by including the lambda function into the test. When I comment out that line I don't get the error. I'm guessing that because this is not a serverless call, Elasticsearch knows nothing of my environment.
test/article.js
console.log("testing articles")
const LambdaTester = require("lambda-tester");
const articleHandler = require("../articles/articleHandler.js");
describe("articles getID()", function() {
it("test success", function() {
return LambdaTester(articleHandler.getID)
.event({pathParameters:{id:5633415102001}})
.expectResult(result => {
expect(result.body.data.id).to.be(5633415102001)
});
});
})
describe("articles getList()", function() {
it("test success", function() {
return LambdaTester(articleHandler.getList)
.event()
.expectResult(reset => {
expect(result.body.data.length).to.be(10);
});
});
});
** ADDITIONAL **
It's looking like lambda-tester is supposed to alleviate the problem I'm encountering. Will find out more today.
Use lamba-tester, there are examples on the github page.
I wrote a simple lambda test function and then tested the output with jasmine + lambda-tester
As for my code, I'll need to refactor the handler someone else wrote before it will work. My simple test looks like:
Serverless yml
testLambda:
handler: test/testLambda.getValueOfA
role: arn:aws:iam::367839381035:role/CodeStarWorker-fx-srch-api-v1-Lambda
events:
- http:
path: test/testLambda/{a}
method: get
Lambda Function
module.exports.getValueOfA = (event, context, callback) => {
let a = 2;
if(event
&& event.pathParameters
&& !isNaN(event.pathParameters.a)
) a = event.pathParameters.a;
a = a+a;
let ret = "the value of a is " + a;
callback(null, ret);
}
Test
const LambdaTester = require("lambda-tester");
const TestLambda = require("./testLambda.js");
describe("testLambda()", function() {
it("test success", function() {
let ret;
LambdaTester(TestLambda.getValueOfA)
.event()
.expectResult(result => {
console.log(result);
expect(result).toEqual("the value of a is 4");
});
});
});
I was going to set this up for parameters but didn't get there. Granted this is enough to get anyone moving forward.
another option you have is to call the function directly from your test. In the end, it's nothing more than a function, so you can import the module and call it, passing the right parameters.

exception when trying to set broadcast flag

I'm working on a dhcp server/client and wanted to try stuff in my home network.
I want to send a DHCPDISCOVER message via udp into my network and catch the answer from my router. Here is my code:
var sender = dgram.createSocket('udp4');
sender.bind();
sender.on('error', function(err) {
console.log(err);
});
sender.setBroadcast(true);
var listener = dgram.createSocket('udp4');
listener.bind(68, function() {
console.log('BOUND');
});
listener.on('message', function(msg, rinfo) {
console.log(msg);
});
sender.send(message, 0, message.length, 67, "255.255.255.255");
But when I try to set the broadcast flag my application crashes.
sudo node main
dgram.js:345
throw errnoException(process._errno, 'setBroadcast');
^
Error: setBroadcast EBADF
at errnoException (dgram.js:454:11)
at Socket.setBroadcast (dgram.js:345:11)
at Object.<anonymous> (/Volumes/Projects/node-dhcp-server/node_modules/module-dhcp/main.js:31:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
felix#felixs-macbook-pro:/Volumes/Projects/node-dhcp-server/node_modules/module-dhcp%
I have no idea why it crashes...
Hmm ok this was an obvious fault ...
Of course the bind() method is asynchronous and I have to set the flag in the callback.
sender.bind( function() { sender.setBroadcast(true) } );

Resources