raddevon
raddevon

Reputation: 3360

How do I find out where my Express app the response is being sent/finished?

I'm getting Error: Can't set headers after they are sent in my app. I know a response is being sent before the response I intend to deliver, but I'm not sure where that's coming from. Can I log to the console when a respnose has been sent? I'm currently using morgan for logging, but it only seems to log requests. I can't find a way to log every response as well.

If not, what is another effective way to hunt this problem down?

Update: This app runs on Azure and uses the Azure SDK for node or else I would try running it through the node debugger or node-inspector. I don't think there's a way to do this while also running the app in the emulator. I could be wrong about that.

Upvotes: 0

Views: 128

Answers (1)

Silom
Silom

Reputation: 746

Your error says that there was a response send already, check your code with the node-inspector or any other debugging tool and search for the spot.

Here the node-inspector.

And since you work with Azure this should help you getting started with the node-inspector.

Upvotes: 1

Related Questions