Git Product home page Git Product logo

azure-functions-nodejs-worker's Introduction

Azure Functions Node.js Worker

Branch Status Runtime Version Support level Node.js Versions
v3.x (default) Build Status Test Status 4 GA 20, 18, 16, 14

NOTE: The branch corresponds to the worker version, which is intentionally decoupled from the runtime version.

Getting Started

Contributing

  • Clone the repository locally and open in VS Code
  • Run "Extensions: Show Recommended Extensions" from the command palette and install all extensions listed under "Workspace Recommendations"
  • Run npm install and npm run build
  • Create or open a local function app to test with
  • In the local function app, add the following settings to your "local.settings.json" file or configure them directly as environment variables
    • languageWorkers__node__workerDirectory: <path to the root of this repository>

    • languageWorkers__node__arguments: --inspect

      ๐Ÿ’ก Tip #1: Set logging__logLevel__Worker to debug if you want to view worker-specific logs in the output of func start

      ๐Ÿ’ก Tip #2: If you need to debug worker initialization, use --inspect-brk instead of --inspect. Just keep in mind you need to attach the debugger within 30 seconds or the host process will timeout.

  • Start the local function app (i.e. run func start or press F5)
  • Back in the worker repository, press F5 and select the process for your running function app
  • Before you submit a PR, run npm run lint and npm test and fix any issues. If you want to debug the tests, switch your launch profile in VS Code to "Launch Unit Tests" and press F5.

Repositories

These are the most important GitHub repositories that make up the Node.js experience on Azure Functions:

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Contributing to TypeScript type definitions

The type definitions supplied by the @azure/functions npm package are located in the types folder. Any changes should be applied directly to ./types/index.d.ts. Please make sure to update the tests in ./types/index.test.ts as well.

azure-functions-nodejs-worker's People

Contributors

alrod avatar castrodd avatar davidmrdavid avatar dependabot[bot] avatar ejizba avatar eliaslopezgt avatar francisco-gamino avatar g-rath avatar hannesne avatar hossam-nasr avatar irnc avatar jamiehaywood avatar kashimiz avatar mhoeger avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar nelak avatar pragnagopa avatar yojagad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-functions-nodejs-worker's Issues

Exception was thrown when upload a 0 byte file

From @fabiocav on March 26, 2018 17:2

From @SimonGuo009 on March 26, 2018 10:10

Portal Environment: https://ms.portal.azure.com
Browser: English/Chrome
Runtime Version: 2.0.11651.0 (~1) (Private Site Extension)

Please refer to the snapshot:
bug2_zerobytefileexception

Repro steps:

  1. Open or create a function app.
  2. Create a function using BlobTriggerWithParameters-JavaScript template.
  3. Upload a 0 byte file in the corresponding blob.
    4.Verify logs for the function.

Copied from original issue: Azure/azure-functions-ux#2467

Copied from original issue: Azure/azure-webjobs-sdk#1645

Failing to load a function throws an exception that crashes the worker

Issue
Failing to load a function throws an exception that crashes the worker because it's not handled.
The functions CLI retries starting the worker up to 2 times more always with the same issue.
image

Expected behaviour
The worker doesn't crash but still shows the appropriate error message for the failing function.
Properly resolved functions loaded under the same worker will still work.

Reproduce steps
Create a function that does not export a function
E.g.:

module.exports = {}

Node Integration Failures

Known test failures:

Increase grpc max message size

Sending an message that was too caused an uncaught exception to be thrown and the worker to shut down. Afterwards, the host shutdown. This may be due to an unrelated timeout error, but should be verified.

Worker xxxx encountered event stream error: { Error: Received message larger than max (5852896 vs. 4194304)
Worker xxxx uncaught exception: { Error: Received message larger than max (5852896 vs. 4194304)

Verbose language worker logging option

It would be nice to have verbose logging in the language worker that can be requested by host.

For example, we remove HTTP header values that evaluate to null, and it would be nice to log when we do that for better debugging.

Clean up HttpMessage

Investigate if some of the properties (raw_response, raw_body can be simplified)

update proto file

headers field in RpcHttp is updated to <string, object> pairs. ToRpcHttp and FromRpcHttp methods in Converters.ts need to be updated.

Host not able to listen on port 50051.

Repro Steps

  1. I used the this snapshot of the host code
  2. I created a Functions App on Azure portal, and uploaded the local-published zip to it using Kudu
  3. I tried to start my Java worker, but it failed to connect to the server
  4. I dumped the logs, and find the related messages below:
2017-06-19T23:40:35.085 address 127.0.0.1 .
2017-06-19T23:40:35.112 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
   at Microsoft.Azure.WebJobs.Script.Rpc.Utilities.IsTcpEndpointAvailable(String addressArgument, Int32 portNumber, TraceWriter systemTraceWriter) in D:\Java\azure-webjobs-sdk-script\src\WebJobs.Script\Rpc\Utilities.cs:line 36
2017-06-19T23:40:35.112 Not listening on port 50051.
  1. I changed the port to 55555, everything just works fine

Take any unit tests from V1 to V2

We should get some tests in place similar to what we had in v1.x Functions for the Edge.js based interop layer.

As an example, the entry point for our v1.x Node unit tests (Mocha tests) is here: https://github.com/Azure/azure-functions-host/blob/v1.x/runNodeTests.cmd. Mocha unit test file here: https://github.com/Azure/azure-functions-host/blob/v1.x/test/WebJobs.Script.Tests.Integration/TestScripts/Node/functions.tests.js. When making changes to the Node interop layer, it was easy to run these locally from the command line.

creating http server fails

Following function fails in V2
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
}).listen(8080);

Need to investigate if this is supported in V1.
In V2, as reported here Azure/azure-functions-host#2321 function fails without any error.

Returning a promise and calling context.done results in an invalid message

If you export a promise instead of a function and call context.done you end up with the wrong error message:
Error: 'done' has already been called. Please check your script for extraneous calls to 'done'.
Where the error should have read:
Error: Choose either to return a promise or call 'done'. Do not use both in your script.
It would seem that the isPromise parameter in Context.ts is never being set to true
Which ends up causing the wrong message to be reported by the worker.
Also as far as I could tell the documentation is nowhere clear on what's the expected behavior when exporting promises and this may be confusing to users.

Beta Runtime's Request Body is a Buffer instead of Object

From @danfsd on May 21, 2018 18:24

Request's body is a <Buffer> instead of object in Azure Function's Runtime Beta. This works fine in the Cloud (which I suppose is running Runtime 1.x

Repro steps

Try to run the boilerplate Javascript code in the Runtime beta:

module.exports = function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    context.log(context.req.body.name);
    if (req.query.name || (req.body && req.body.name)) {
        context.res = {
            // status: 200, /* Defaults to 200 */
            body: "Hello " + (req.query.name || req.body.name)
        };
    }
    else {
        context.res = {
            status: 400,
            body: "Please pass a name on the query string or in the request body"
        };
    }
    context.done();
};

Expected behavior

The context.log(context.req.body.name) should log:

2018-05-21T17:41:12.509 [Info] daniel

Actual behavior

Instead, it's logging:

<Buffer 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 33 30 38 32 35 30 31 33 36 35 39 30 36 31 38 38 37 30 38 32 36 32 ... >

Known workarounds

This scenario works just fine under the Runtime 1.x running on Azure Functions.

Copied from original issue: Azure/azure-functions-host#2875

Add system logs

  • Add verbose and info level system logs with option to turn on verbose logging when debugging

Node 10 support

Although Node 8 is under long-term support, Node 9 is current. Any install via brew or chocolatey will default to Node 9, which creates a bad experience for local developers that install node for the first time on a machine and must downgrade to 8.

UPDATE: node 10 just released

Let user configure option to error if on empty event loop

"What Lambda is doing is looking for your event loop to be empty, and if it is, stopping the execution."

We could allow users to configure settings to more defensively look for coding errors of not calling done/next by looking at the event loop and seeing if we should stop execution but aren't.

This could prevent users from seeing functions that just hang.

Original request: https://stackoverflow.com/questions/47584690/azure-function-hangs-on-error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.