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

Upload file error - IllegalArgumentException: should should be greater than write space + end gap #956

Closed
galex opened this issue Feb 15, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@galex
Copy link

galex commented Feb 15, 2019

Ktor Version

1.1.2

Ktor Engine Used(client or server and name)

  • Multiplatform project uses ktor-client-core in its common sourceset and ktor-client-js in its javascript sourceset.
  • Kotlin react app depends on its multiplatform artifact
  • Backend JVM Ktor app depends on its multiplatform artifact a well

JVM Version, Operating System and Relevant Context

Running on Mac OS X Mojave

Feedback

I am trying to upload files from the kotlin react app to the backend. It works fine for little sized files but as soon as I try to upload a file bigger than ~1MB I get the following error:

IllegalArgumentException: should should be greater than write space + end gap (size = 9, writeRemaining = 0, endGap = 8, rem+gap = 8
    at IllegalArgumentException_init_0 (http://localhost:9000/bundle.js:162304:32)
    at require$ObjectLiteral_1.doFail (http://localhost:9000/bundle.js:34344:9)
    at IoBuffer.writeBufferAppend_ehtrw3$ (http://localhost:9000/bundle.js:35661:7)
    at ByteReadPacket_0.ByteReadPacketBase.prepareRead_87ik6q$ (http://localhost:9000/bundle.js:31628:10)
    at ByteReadPacket_0.ByteReadPacketBase.readAsMuchAsPossible_v6e8td$_0 (http://localhost:9000/bundle.js:31444:15)
    at ByteReadPacket_0.ByteReadPacketBase.readAsMuchAsPossible_v6e8td$_0 (http://localhost:9000/bundle.js:31455:19)
    at ByteReadPacket_0.ByteReadPacketBase.readAsMuchAsPossible_v6e8td$_0 (http://localhost:9000/bundle.js:31455:19)
    at ByteReadPacket_0.ByteReadPacketBase.readAsMuchAsPossible_v6e8td$_0 (http://localhost:9000/bundle.js:31455:19)
    at ByteReadPacket_0.ByteReadPacketBase.readAsMuchAsPossible_v6e8td$_0 (http://localhost:9000/bundle.js:31455:19)
    at ByteReadPacket_0.ByteReadPacketBase.readAsMuchAsPossible_v6e8td$_0 (http://localhost:9000/bundle.js:31455:19)"

The network request functions are written in the multiplatform commainMain sourceset so that they can be shared with Android and iOS in the future. I tried using .post, .submitForm and .submitFormWithBinaryData without seeing any success.

Here's a repo with the 3 projects side by side for you to reproduce the issue: https://github.com/galex/reproducer-bug-ktor

Thank you,
Alex

@cy6erGn0m cy6erGn0m self-assigned this Feb 15, 2019
@cy6erGn0m
Copy link
Contributor

That's quite interesting state when size = 9 here. I'll investigate it asap.

@cy6erGn0m cy6erGn0m added the bug label Feb 15, 2019
@cy6erGn0m cy6erGn0m added this to the 1.2.1 milestone Feb 15, 2019
cy6erGn0m pushed a commit to Kotlin/kotlinx-io that referenced this issue Feb 15, 2019
cy6erGn0m pushed a commit to Kotlin/kotlinx-io that referenced this issue Feb 15, 2019
@galex
Copy link
Author

galex commented Feb 21, 2019

Is there a nightly build or something to test the fix?

@cy6erGn0m
Copy link
Contributor

Fixed in 1.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants