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

MultipartReader fails with UnexpectedEof if using --no-check or compille #9620

Closed
vinc3m1 opened this issue Feb 27, 2021 · 8 comments
Closed
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)

Comments

@vinc3m1
Copy link

vinc3m1 commented Feb 27, 2021

Same issue as #7932, not sure why the author closed that bug.

error: Uncaught (in promise) UnexpectedEof
  private isBoundaryDelimiterLine(line: Uint8Array): boolean {
^
    at MultipartReader.nextPart (https://deno.land/std@0.88.0/mime/multipart.ts:413:1)
    at async MultipartReader.readForm (https://deno.land/std@0.88.0/mime/multipart.ts:319:1)

I first found this only happening when I compiled my script to a binary (compile --unstable).
Then, after finding #7932, I tested --no-check and it results in the same error.

Code works just fine with regular deno run

std@0.88.0
deno 1.7.5

@vinc3m1 vinc3m1 changed the title MultipartReader fails with UnexpectedEof if using --no-check or compille MultipartReader fails with UnexpectedEof if using --no-check or compille, and with trailing newline Feb 27, 2021
@vinc3m1 vinc3m1 closed this as completed Feb 27, 2021
@vinc3m1 vinc3m1 reopened this Feb 28, 2021
@vinc3m1
Copy link
Author

vinc3m1 commented Feb 28, 2021

It seems that after running with --no-check, the broken deps are cached and subsequent runs withouth the --no-cache flag still fail, even with --reload.

test file:

import { MultipartReader } from "https://deno.land/std@0.88.0/mime/multipart.ts";
import { StringReader } from "https://deno.land/std@0.88.0/io/readers.ts";

// carriage returns added for running on POSIX, not needed if on windows
const content = `--------------------------366796e1c748a2fb\r
Content-Disposition: form-data; name="payload"\r
Content-Type: text/plain\r
\r
CONTENT\r
--------------------------366796e1c748a2fb--`

const boundary = "------------------------366796e1c748a2fb";

const stringReader = new StringReader(content);

const multipartReader = new MultipartReader(stringReader, boundary);
const formData = await multipartReader.readForm()
for (const entry of formData.entries()) {
  console.log("entry", entry);
}
console.log("formdata", formData);

output:

$ deno run test.ts
Check file:///.../test.ts
entry [ "payload", "CONTENT" ]
formdata {
  file: [Function: file],
  value: [Function: value],
  entries: [GeneratorFunction: entries],
  removeAll: [AsyncFunction: removeAll],
  [Symbol(Symbol.iterator)]: [Function: [Symbol.iterator]]
}

$ deno run test.ts
Check file:///.../test.ts
entry [ "payload", "CONTENT" ]
formdata {
  file: [Function: file],
  value: [Function: value],
  entries: [GeneratorFunction: entries],
  removeAll: [AsyncFunction: removeAll],
  [Symbol(Symbol.iterator)]: [Function: [Symbol.iterator]]
}

$ deno run --no-check test.ts
error: Uncaught UnexpectedEof
  private isBoundaryDelimiterLine(line: Uint8Array): boolean {
^
    at MultipartReader.nextPart (https://deno.land/std@0.88.0/mime/multipart.ts:413:1)
    at async MultipartReader.readForm (https://deno.land/std@0.88.0/mime/multipart.ts:319:1)
    at async file:///.../test.ts:16:1

$ deno run test.ts
Check file:///.../test.ts
error: Uncaught UnexpectedEof
  private isBoundaryDelimiterLine(line: Uint8Array): boolean {
^
    at MultipartReader.nextPart (https://deno.land/std@0.88.0/mime/multipart.ts:413:1)
    at async MultipartReader.readForm (https://deno.land/std@0.88.0/mime/multipart.ts:319:1)
    at async file:///.../test.ts:16:18

$ deno run -r test.ts
Download https://deno.land/std@0.88.0/mime/multipart.ts
Download https://deno.land/std@0.88.0/io/readers.ts
Download https://deno.land/std@0.88.0/io/bufio.ts
Download https://deno.land/std@0.88.0/_util/assert.ts
Download https://deno.land/std@0.88.0/_util/has_own_property.ts
Download https://deno.land/std@0.88.0/bytes/mod.ts
Download https://deno.land/std@0.88.0/io/ioutil.ts
Download https://deno.land/std@0.88.0/textproto/mod.ts
Download https://deno.land/std@0.88.0/path/mod.ts
Download https://deno.land/std@0.88.0/path/posix.ts
Download https://deno.land/std@0.88.0/path/separator.ts
Download https://deno.land/std@0.88.0/path/glob.ts
Download https://deno.land/std@0.88.0/path/win32.ts
Download https://deno.land/std@0.88.0/_util/os.ts
Download https://deno.land/std@0.88.0/path/common.ts
Download https://deno.land/std@0.88.0/path/_interface.ts
Download https://deno.land/std@0.88.0/path/_constants.ts
Download https://deno.land/std@0.88.0/path/_util.ts
Check file:///home/vince/vinc3m1/plexbot/test.ts
error: Uncaught UnexpectedEof
  private isBoundaryDelimiterLine(line: Uint8Array): boolean {
^
    at MultipartReader.nextPart (https://deno.land/std@0.88.0/mime/multipart.ts:413:1)
    at async MultipartReader.readForm (https://deno.land/std@0.88.0/mime/multipart.ts:319:1)
    at async file:///.../test.ts:16:18

@vinc3m1 vinc3m1 changed the title MultipartReader fails with UnexpectedEof if using --no-check or compille, and with trailing newline MultipartReader fails with UnexpectedEof if using --no-check or compille Feb 28, 2021
@kitsonk kitsonk added bug Something isn't working correctly swc related to swc (bundling/transpiling) labels Mar 2, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Mar 2, 2021

cc/ @kdy1 I haven't narrowed it down yet, but it looks like there is some problem with the output of transpiling.

kdy1 added a commit to kdy1/swc that referenced this issue Mar 3, 2021
kdy1 added a commit to swc-project/swc that referenced this issue Mar 3, 2021
swc_ecma_parser:
 - Fix lexing of template literals. (denoland/deno#9620)
 - Ensure that denoland/deno#9650 is not a bug of parser.
@nayeemrmn
Copy link
Collaborator

I recognise this error, it's what lead me to track down and open swc-project/swc#930. In other words this is #9773 seen in https://github.com/denoland/deno_std/blob/0.90.0/mime/multipart.ts#L264-L269. It will also be fixed by #9774, once we adapt that code to the additional "useDefineForClassFields" restrictions.

@nayeemrmn
Copy link
Collaborator

Fixed by denoland/std#807.

@vinc3m1
Copy link
Author

vinc3m1 commented Mar 29, 2021

While this seems to have fixed the --no-check case, the compile --unstable case is still broken using the test script linked to in #9620 (comment):

$ deno compile --unstable test.ts
[...]
Emit test
$ ./test
error: ReferenceError: matchAfterPrefix is not defined
    at scanUntilBoundary (file://$deno$/bundle.js:1702:9)
    at PartReader.read (file://$deno$/bundle.js:1737:22)
    at async copyN (file://$deno$/bundle.js:107:24)
    at async MultipartReader.readForm (file://$deno$/bundle.js:1825:27)
    at async file://$deno$/bundle.js:2095:18

But running with --no-check passes now so that's good:

$ deno run --no-check test.ts
entry [ "payload", "CONTENT" ]
formdata {
  file: [Function: file],
  value: [Function: value],
  entries: [GeneratorFunction: entries],
  removeAll: [AsyncFunction: removeAll],
  [Symbol(Symbol.iterator)]: [Function: [Symbol.iterator]]
}

@nayeemrmn
Copy link
Collaborator

@vinc3m1 For tracking purposes, can you open a separate issue for that?

@bartlomieju
Copy link
Member

Fixed in 1.9.0

@vinc3m1
Copy link
Author

vinc3m1 commented Apr 14, 2021

@vinc3m1 For tracking purposes, can you open a separate issue for that?

Sure, created a separate issue to track: #10187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)
Projects
None yet
Development

No branches or pull requests

4 participants