Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using nodejs microcule.plugins.spawn doesn't close connection #39

Open
mphuie opened this issue Jul 25, 2017 · 7 comments
Open

Using nodejs microcule.plugins.spawn doesn't close connection #39

mphuie opened this issue Jul 25, 2017 · 7 comments

Comments

@mphuie
Copy link

mphuie commented Jul 25, 2017

The expressjs examples from https://github.com/Stackvana/microcule/tree/master/examples, don't close the connection. Only the javascript code example works as there is a res.end() in it.

@mphuie mphuie changed the title Using nodejs microcule.plugins.spawn close connection Using nodejs microcule.plugins.spawn doesn't close connection Jul 25, 2017
@mphuie
Copy link
Author

mphuie commented Jul 25, 2017

This is on OS X 10.12.4 with Node v6.9.5

@Marak
Copy link
Collaborator

Marak commented Jul 25, 2017

Can you be more specific which example you are having issues with?

There should be a mechanism in place which ends the request when the script completes. It's possible I failed to port over this functionality from hook.io, but I know we did create a way for this to work.

@Marak
Copy link
Collaborator

Marak commented Jul 25, 2017

I think I got it, one moment.

@Marak
Copy link
Collaborator

Marak commented Jul 25, 2017

@mphuie - I think I got it. This makes sense. I must have forgotten to update the examples to use the new API semantics.

If you look at https://github.com/Stackvana/microcule/blob/master/examples/express-python.js#L19, you'll see it's now updated and should be working.

Basically, if the response isn't closed inside of a script, we need to have a middleware at the end of the server to catch and close the response. This will only fire if the script itself doesn't close the response.

I'll take the time to update the other examples and see about adding documentation for explicitly closing the request inside non-JS services.

Does that work for you?

@mphuie
Copy link
Author

mphuie commented Jul 25, 2017

Yep, that works, doesn't that mean the server will return a 200 regardless of exit code?

@Marak
Copy link
Collaborator

Marak commented Jul 25, 2017

I think right now, it's up to the developer to determine which HTTP status will be sent back into the response. It would probably be correct for us to provide a configurable mapping of HTTP response codes to the exit codes. I believe hook.io is doing this already to some extent.

If you could post some example code or scenarios with what you would expect to see as a result, I would be glad to review and see if we can incorporate it into the project.

Thank you for your feedback.

Marak added a commit that referenced this issue Dec 1, 2017
  * Switches default back to end response on exit
    * Least surprising behavior for users 
    * Is more frequent use-case
  * Adds configuration options for chaining
  * Updates examples and tests to new API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants