RejectedSoftware Forums

Sign up

Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

Hi All!

I am movice in D and try to learn Vibe.d. Now I have error which don't know how to deal with because it's deep in framework. Server answers by empty page on every request and shows in console one more exception. Is this known problem or no?
Thanks.

`
Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

0x004C005D in void std.zlib.Compress.error(int)
0x0048A9F1 in void vibe.http.server.HTTPServerResponse.writeBody(const(ubyte[]), immutable(char)[]) at C:\www\D\http\testserver........\Users\crimaniak\AppData\Roam
ing\dub\packages\vibe-d-0.7.17\source\vibe\http\server.d(652)
0x0048AA44 in void vibe.http.server.HTTPServerResponse.writeBody(immutable(char)[], immutable(char)[]) at C:\www\D\http\testserver........\Users\crimaniak\AppData\R
oaming\dub\packages\vibe-d-0.7.17\source\vibe\http\server.d(657)
0x0040378B in void app.api4(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) at C:\www\D\http\testserver\source\app.d(22)
0x00434D3B in void std.functional.DelegateFaker!(void function(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)).DelegateFaker.doIt(vibe.http.s
erver.HTTPServerRequest, vibe.http.server.HTTPServerResponse) at C:\D\dmd2\windows\bin\..\..\src\phobos\std\functional.d(706)
0x004896FC in void vibe.http.router.URLRouter.handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) at C:\www\D\http\testserver\..\..\.
.\..\Users\crimaniak\AppData\Roaming\dub\packages\vibe-d-0.7.17\source\vibe\http\router.d(160)
0x0048DBAF in bool vibe.http.server.handleRequest(vibe.core.stream.Stream, immutable(char)[], vibe.http.server.HTTPServerListener, ref vibe.http.server.HTTPServerSettin
gs, ref bool) at C:\www\D\http\testserver\..\..\..\..\Users\crimaniak\AppData\Roaming\dub\packages\vibe-d-0.7.17\source\vibe\http\server.d(1278)
0x0048CBB7 in void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPServerListener) at C:\www\D\http\testserver\..\..\..\..\Users
\crimaniak\AppData\Roaming\dub\packages\vibe-d-0.7.17\source\vibe\http\server.d(1069)
0x0048A091 in D4vibe4http6server15listenHTTPPlainFC4vibe4http6server18HTTPServerSettingsDFC4vibe4http6server1641FA09B7174DBCE768131F5B893A31F at C:\www\D\http\testserve
r\..\..\..\..\Users\crimaniak\AppData\Roaming\dub\packages\vibe-d-0.7.17\source\vibe\http\server.d(122)
0x00453424 in extern (C) nothrow void vibe.core.drivers.libevent2_tcp.onConnect(int, short, void
).void ClientTask.execute() at C:\www\D\http\testserver........\Use
rs\crimaniak\AppData\Roaming\dub\packages\vibe-d-0.7.17\source\vibe\core\drivers\libevent2_tcp.d(442)
0x00447488 in void vibe.core.core.CoreTask.run() at C:\www\D\http\testserver........\Users\crimaniak\AppData\Roaming\dub\packages\vibe-d-0.7.17\source\vibe\core\cor
e.d(589)
0x004C3E59 in void core.thread.Fiber.run()
0xFFFFFFFF
0x76FA37CE in wcstombs
`

Re: Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

Am 14.11.2013 19:42, schrieb Alexey Kulentsov:

Hi All!

I am movice in D and try to learn Vibe.d. Now I have error which don't know how to deal with because it's deep in framework. Server answers by empty page on every request and shows in console one more exception. Is this known problem or no?
Thanks.

<br>Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error<br>(...)<br>

This should be fixed on git HEAD and on the latest 0.7.18-beta.1. Try to
see if a "dub upgrade" makes it go away.

Re: Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

On Thu, 14 Nov 2013 23:06:59 +0100, Sönke Ludwig wrote:

This should be fixed on git HEAD and on the latest 0.7.18-beta.1. Try to
see if a "dub upgrade" makes it go away.

First I did this, vibe was upgraded but nothing changes. Then I make some experiments. Error was only with request from browser, I make utility to request server and here was no this error. Difference was in headers - utility didn't get Accept-Encoding: gzip, deflate so server didn't try to compress output stream. Then I download sources from git, check it and here was no any problems. So I start to exploring difference between source and dub-managed versions. At this moment here come one more upgrade for libevent, openssl and libev packets and this bug was fixed. Thanks to authors!

But now I have one more question. When I tried to disable output stream compressing I didn't found any way to control output stream format. I expected to see something like PHP's zlib.output_compression flag in HTTPServerSettings or HTTPServerOption, but nothing is here. Is here any way to manage this?

Re: Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

On Fri, 15 Nov 2013 13:38:28 GMT, Alexey Kulentsov wrote:

On Thu, 14 Nov 2013 23:06:59 +0100, Sönke Ludwig wrote:

This should be fixed on git HEAD and on the latest 0.7.18-beta.1. Try to
see if a "dub upgrade" makes it go away.

First I did this, vibe was upgraded but nothing changes. Then I make some experiments. Error was only with request from browser, I make utility to request server and here was no this error. Difference was in headers - utility didn't get Accept-Encoding: gzip, deflate so server didn't try to compress output stream. Then I download sources from git, check it and here was no any problems. So I start to exploring difference between source and dub-managed versions. At this moment here come one more upgrade for libevent, openssl and libev packets and this bug was fixed. Thanks to authors!

But now I have one more question. When I tried to disable output stream compressing I didn't found any way to control output stream format. I expected to see something like PHP's zlib.output_compression flag in HTTPServerSettings or HTTPServerOption, but nothing is here. Is here any way to manage this?

Currently there is no setting to disable it, but you can do if ("Content-Encoding" in res.headers) res.headers.remove("Content-Encoding"); on the response object to disable compression. If you are using a URLRouter, you can use it to disable compression for all requests:

void disableCompression(HTTPServerRequest req, HTTPServerResponse res) {
	if ("Content-Encoding" in res.headers) res.headers.remove("Content-Encoding");
}

auto router = new URLRouter;
router.any("*", &disableCompression);
// ... register all normal roues

Re: Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

On Fri, 15 Nov 2013 14:50:47 GMT, Sönke Ludwig wrote:

Currently there is no setting to disable it, but you can do if ("Content-Encoding" in res.headers) res.headers.remove("Content-Encoding"); on the response object to disable compression.

Therefore, control of the output stream through an array of headers? The solution is not obvious to me. Thanks!

Re: Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

Am 17.11.2013 02:05, schrieb Alexey Kulentsov:

On Fri, 15 Nov 2013 14:50:47 GMT, Sönke Ludwig wrote:

Currently there is no setting to disable it, but you can do if ("Content-Encoding" in res.headers) res.headers.remove("Content-Encoding"); on the response object to disable compression.

Therefore, control of the output stream through an array of headers? The solution is not obvious to me. Thanks!

The HTTP server works like this regarding compression:

  1. read the request header
  2. check if there is an Accept-Encoding header present
  3. if true, set a Content-Encoding header on the response
  4. call the user request handler callback
  5. before the response body is written, check if a Content-Encoding
    header is present
  6. if true, wrap the response output stream in the proper
    GzipOutputStream or similar
  7. write the response body

It's done like this to ensure that response headers are always
consistent with the actual encoding/compression used to send the data.

Re: Error after page has been written: std.zlib.ZlibException@std\zlib.d(59): mem error

On Fri, 15 Nov 2013 13:38:28 GMT, Alexey Kulentsov wrote:

On Thu, 14 Nov 2013 23:06:59 +0100, Sönke Ludwig wrote:

This should be fixed on git HEAD and on the latest 0.7.18-beta.1. Try to
see if a "dub upgrade" makes it go away.

First I did this, vibe was upgraded but nothing changes. Then I make some experiments. Error was only with request from browser, I make utility to request server and here was no this error. Difference was in headers - utility didn't get Accept-Encoding: gzip, deflate so server didn't try to compress output stream. Then I download sources from git, check it and here was no any problems. So I start to exploring difference between source and dub-managed versions. At this moment here come one more upgrade for libevent, openssl and libev packets and this bug was fixed. Thanks to authors!

But now I have one more question. When I tried to disable output stream compressing I didn't found any way to control output stream format. I expected to see something like PHP's zlib.output_compression flag in HTTPServerSettings or HTTPServerOption, but nothing is here. Is here any way to manage this?

Update: Compression is now (git master, 119b050) controlled by HTTPServerSettings.useCompressionIfPossible and disabled by default (because it still seems to cause issues, see this reddit comment).