question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2.0 seems to have broken static file serving on azure.

See original GitHub issue

I have the following code in my function-app:

app.use("/", express.static("www"));

This results in the following runtime exception:

2018-09-07T22:14:29.829 [Info] Function started (Id=65d1f81f-f1ed-4d9f-844e-7fdcae8cf5c6)
2018-09-07T22:14:31.782 [Error] A ScriptHost error has occurred
2018-09-07T22:14:31.782 [Error] System.InvalidOperationException : TypeError: Cannot read property 'length' of null
    at ServerResponse.OutgoingMessage._send (_http_outgoing.js:137:38)
    at ServerResponse.OutgoingMessage.write (_http_outgoing.js:491:16)
    at ReadStream.ondata (_stream_readable.js:555:20)
    at emitOne (events.js:96:13)
    at ReadStream.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at ReadStream.Readable.push (_stream_readable.js:134:10)
    at onread (fs.js:2018:12)
    at FSReqWrap.wrapper [as oncomplete] (fs.js:682:17)

Note the calls into the new methods inherited by OutgoingMessage.

I’m not sure what’s up here but i think this starting breaking when the change to derive from NativeOutgoingMessage. Do you know what’s up @yvele ? Do you have a recommendation on what can be used instead?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kfhak-zbcommented, Feb 20, 2019

maybe it’s related in “OutgoingMessage.js”

I changed “OutgoingMessage.js” like below

function convertToBody(body, encoding) {

// return Buffer.isBuffer(body) ? body.toString(encoding) : body; //origin code return Buffer.isBuffer(body) && “binary” != encoding ? body.toString(encoding) : body;

}

and test like this

app.get(“/api/getfile”, function (req, res) {

const data = fs.readFileSync("sample.pdf");

res.writeHead(200, {

	"Content-Type": "application/pdf",

	"Content-Disposition": "attachment;filename=output.pdf"

});

res.end(data, "binary");

});

It downloaded the file without “TypeError: Cannot read property ‘length’ of null”

1reaction
lworkmancommented, Feb 19, 2019

That’s for the tip @CyrusNajmabadi , I found a different library that implemented aws-serverless-express for azure and it worked like a charm (https://github.com/bigx333/azure-aws-serverless-express).

@yvele I do really like this library, and would switch back once this issue gets fixed. To give you more details, I was trying to serve a ReadableStream from azure blob storage through express and kept running into the headers issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure static files System.IO.DirectoryNotFoundException
Make sure your static files are part of your project. And mark them explicitly as content and Copy to output folder -> always....
Read more >
Troubleshoot domain and TLS/SSL certificates - Azure App ...
Find solutions to the common problems that you might encounter when you configure a domain or TLS/SSL certificate in Azure App Service.
Read more >
Troubleshooting Azure Static Web Apps - Microsoft Learn
Review server errors · Inside the Azure portal, open the Resource Group associated with your static web app. · Select the Application Insights ......
Read more >
Limitations & known issues with SFTP in Azure Blob Storage
Learn about limitations and known issues of SSH File Transfer Protocol (SFTP) support for Azure Blob Storage.
Read more >
Release notes & updates – Azure CLI - Microsoft Learn
Learn about the latest Azure Command-Line Interface (CLI) release notes and updates for both the current and beta versions of the CLI.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found