spajak / cef-pdf

cef-pdf HTML to PDF utility
MIT License
77 stars 33 forks source link

Clean up when HTTP connection closed. #17

Open beckyconning opened 6 years ago

beckyconning commented 6 years ago

Load end may never occur its important to clean up when connection is closed.

spajak commented 6 years ago

Could you find the real example when this case happens?

beckyconning commented 6 years ago

node -e "require('http').createServer().listen(8080)"

http connections being left open for a long time is a typical feature. it is commonly found in report generation. http connections being left open indefinitely could happen either purposefully or accidentally on pretty much any web server.

beckyconning commented 6 years ago

E.g.

cef-pdf --server & node -e "require('http').createServer().listen(8080)" & curl -X POST http://localhost:9288/_.pdf --header "Content-Location: http://localhost:8080"

the curl request will never finish and when i close it the cef-pdf process which was spawned continues forever. after a duration the entire cef-pdf http server crashes with a segmentation fault.

beckyconning commented 6 years ago

to act as a resilient http service cef-pdf must keep its connections as a client and as a server alive, must clean up allocated resources on a connection by connection basis as these connections are closed and must not crash.