mbari-org / oni

Organism Naming Infrastructure
https://mbari-org.github.io/oni/
0 stars 0 forks source link

Call to `v1/links/{name}` fails when the return data is very large #3

Closed hohonuuli closed 1 week ago

hohonuuli commented 1 week ago

Test URL: http://localhost:8083/v1/links/Aegina

The server throws this error:

2024-06-29 16:31:45 2024-06-29 23:31:45 [[0x77434ce7 0x3d903657] WebServer socket] WARN  io.helidon.webserver.http.ErrorHandlers            | [0x77434ce7 0x3d903657] Request failed: HttpPrologue[protocol=HTTP, protocolVersion=1.1, method=GET, uriPath=/v1/links/Aegina, query=, fragment=], cannot send error response, as response already sent
2024-06-29 16:31:45 io.helidon.http.RequestException: Index 31140 out of bounds for length 31140
2024-06-29 16:31:45     at io.helidon.http.RequestException$Builder.build(RequestException.java:139)
2024-06-29 16:31:45     at io.helidon.webserver.http.ErrorHandlers.unhandledError(ErrorHandlers.java:202)
2024-06-29 16:31:45     at io.helidon.webserver.http.ErrorHandlers.lambda$handleError$1(ErrorHandlers.java:182)
2024-06-29 16:31:45     at java.base/java.util.Optional.ifPresentOrElse(Optional.java:198)
2024-06-29 16:31:45     at io.helidon.webserver.http.ErrorHandlers.handleError(ErrorHandlers.java:181)
2024-06-29 16:31:45     at io.helidon.webserver.http.ErrorHandlers.runWithErrorHandling(ErrorHandlers.java:118)
2024-06-29 16:31:45     at io.helidon.webserver.http.Filters.filter(Filters.java:77)
2024-06-29 16:31:45     at io.helidon.webserver.http.HttpRouting.route(HttpRouting.java:109)
2024-06-29 16:31:45     at io.helidon.webserver.http1.Http1Connection.route(Http1Connection.java:332)
2024-06-29 16:31:45     at io.helidon.webserver.http1.Http1Connection.handle(Http1Connection.java:169)
2024-06-29 16:31:45     at io.helidon.webserver.ConnectionHandler.run(ConnectionHandler.java:155)
2024-06-29 16:31:45     at io.helidon.common.task.InterruptableTask.call(InterruptableTask.java:47)
2024-06-29 16:31:45     at io.helidon.webserver.ThreadPerTaskExecutor$ThreadBoundFuture.run(ThreadPerTaskExecutor.java:239)
2024-06-29 16:31:45     at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)
2024-06-29 16:31:45 Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 31140 out of bounds for length 31140
2024-06-29 16:31:45     at io.helidon.common.buffers.FixedBufferData.write(FixedBufferData.java:126)
2024-06-29 16:31:45     at io.helidon.common.buffers.FixedBufferData.write(FixedBufferData.java:26)
2024-06-29 16:31:45     at io.helidon.webserver.http1.Http1ServerResponse$BlockingOutputStream.writeChunked(Http1ServerResponse.java:659)
2024-06-29 16:31:45     at io.helidon.webserver.http1.Http1ServerResponse$BlockingOutputStream.write(Http1ServerResponse.java:587)
2024-06-29 16:31:45     at io.helidon.webserver.http1.Http1ServerResponse$BlockingOutputStream.write(Http1ServerResponse.java:438)
2024-06-29 16:31:45     at java.base/java.io.BufferedOutputStream.implWrite(BufferedOutputStream.java:217)
2024-06-29 16:31:45     at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:206)
2024-06-29 16:31:45     at java.base/java.io.ByteArrayInputStream.transferTo(ByteArrayInputStream.java:213)
2024-06-29 16:31:45     at sttp.tapir.server.nima.NimaServerInterpreter.toHandler$$anonfun$1$$anonfun$4(NimaServerInterpreter.scala:45)
2024-06-29 16:31:45     at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
2024-06-29 16:31:45     at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
2024-06-29 16:31:45     at scala.Option.fold(Option.scala:263)
2024-06-29 16:31:45     at sttp.tapir.server.nima.NimaServerInterpreter.toHandler$$anonfun$1(NimaServerInterpreter.scala:48)
2024-06-29 16:31:45     at io.helidon.webserver.http.HttpRouting$RoutingExecutor.doRoute(HttpRouting.java:668)
2024-06-29 16:31:45     at io.helidon.webserver.http.HttpRouting$RoutingExecutor.call(HttpRouting.java:627)
2024-06-29 16:31:45     at io.helidon.webserver.http.HttpRouting$RoutingExecutor.call(HttpRouting.java:605)
2024-06-29 16:31:45     at io.helidon.webserver.http.ErrorHandlers.runWithErrorHandling(ErrorHandlers.java:75)
2024-06-29 16:31:45     ... 8 common frames omitted

We expect the data like: http://m3.shore.mbari.org/kb/v1/links/Aegina

hohonuuli commented 1 week ago

Using larger write buffer on helidon's webserver fixed this.

WebServer
     .builder()
     .writeBufferSize(131072)   // Big buffer to handle full kb tree