GithubHelp home page GithubHelp logo

Comments (11)

sinedied avatar sinedied commented on April 18, 2024 1

Sorry for the spam, seems a workaround has already been proposed to azure-function-express, but is still not merged after many months: yvele/azure-function-express#31

from azure-func-http.

sergfa avatar sergfa commented on April 18, 2024 1

Thanks @sinedied, your workaround solved this problem in my env.
I'm posting a code snippet so others can use it until the fix will be merged.

// main/index.ts

export default function(context: Context, req: HttpRequest): void {
  req['_body'] = true;
  AzureHttpAdapter.handle(createApp, context, req);
}

from azure-func-http.

kamilmysliwiec avatar kamilmysliwiec commented on April 18, 2024 1

Thanks for sharing @sinedied. I've added this workaround to the AzureHttpAdapter and published as a new version.

from azure-func-http.

sinedied avatar sinedied commented on April 18, 2024

I forgot to mention that when I say "not working", the request gets stuck with no response at all and timeout.
From the logs I can see the request being received by the functions emulator when running locally from the logs, but it doesn't seem to get forwarded to the "real" NestJS handler as I see no logs from my controller handler.

from azure-func-http.

sinedied avatar sinedied commented on April 18, 2024

Ok, I did some extensive debugging this morning and found the cause of the issue: the functions runtime already parse the JSON body and provide it to the req object, but the underlying express layer tries to parse the body agains and gets stuck decoding the input stream, surely because the functions runtime already exhausted it. Did a quick workaround by adding req._body = true in the Azure http handler before giving the hand to the NestJS handler and that fixed the issue.

Though I willing to open a PR to fix this, I would like some advice on what you think would be the best approach to solve this? I'm also wondering about the upstream package azure-express-functions which I guess should have the issue too?

from azure-func-http.

sinedied avatar sinedied commented on April 18, 2024

Thanks @kamilmysliwiec , but to be honest this workaround was not meant for production as it doesn't solve all issues here, for example file upload are still not working.
In fact, any other express middleware other than express/body-json will still be failing, unless that PR: yvele/azure-function-express#31 is merged.

I can't find any way to contact the original author of azure-function-express as he doesn't respond on github and have its DM closed on twitter. There's no sign of recent activity from him on this project since almost a year 😢
I'm tempted to fork the project, merge the bugfix PRs and publish a new package on NPM to unblock the issue as it's quite problematic.
Would you accept a PR to (temporarily) use that fork to address the issue?

Meanwhile I'm still trying to contact the original author, as the best fix would still best to be upstream.

from azure-func-http.

kamilmysliwiec avatar kamilmysliwiec commented on April 18, 2024

Would you accept a PR to (temporarily) use that fork to address the issue?

@sinedied maybe we should no longer use the "azure-function-express" and just bring the entire functionality here? Hence, we won't be dependent on them in the future. This package seems to be fairly small either way. Would you like to contribute to this and (if so) create a PR?

from azure-func-http.

sinedied avatar sinedied commented on April 18, 2024

@kamilmysliwiec even better, I'll work on that. Do you want to reopen this issue or should I open a new one to track the changes?

from azure-func-http.

kamilmysliwiec avatar kamilmysliwiec commented on April 18, 2024

I would suggest creating a new one:)

from azure-func-http.

dcollien avatar dcollien commented on April 18, 2024

@sinedied I shared your frustration regarding azure-function-express and have moved my own dependencies over to use https://github.com/mikestaub/serverless-express (added benefit of it now being deployable on 3 clouds)

from azure-func-http.

jpgilchrist avatar jpgilchrist commented on April 18, 2024

@dcollien I'm interested in that too, I saw your PR there for the stream IncomingMessage fix. This thread is probably not the best place for this conversation, but I don't have a better spot for it. Do you have a mini guide on migrating from azure-functions-express to serverless-express?

from azure-func-http.

Related Issues (20)

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.