End_of_file Exception when compiling

bsb
reasonreact

#1

Sometimes i get this error when compiling my ReasonML (ReasonReact) project. After trying 2-3 times, it works without any problems. But this keeps me from running build on my Project because everytime it tries to compile, this error gets thrown with another file.

Does anyone have a solution for this? :open_mouth: Thanks in advance!

Failed to compile.

./src/login.re
    at Array.map (<anonymous>)tal error: exception End_of_file
    at <anonymous>

Versions:
bs-platform: 4.0.0 (updated today, hat the same with 3.1.5)
reason-react: 0.4.2
bs-loader: 2.0.5 (reason-scripts 0.9.0)


#2

What do you mean by ‘trying 2-3 times’? What did you try?

Could you share what’s going on in login.re?

I don’t think this is the cause for compilation to fail, but your file name should be capitalized.


#3

Sorry, compiling 2-3 Times. (Saving a file to trigger a new compile or Running yarn start again)

I cannot share the complete file. But it is always different file that throws the error. Kind of random. i have like 15 .re files. Ill try to recreate the behaviour with some example files that i can share with you. Im also going to use the uppercase file nameing.
I guess it must be a package im using in this project.

(Also the Login.re file does not have a line with „Array.map…“ :thinking:)


#4

Hmm…that is strange! Could your build be stale? Have you tried cleaning your build?


#5

i just tried that and it did not help :frowning:

Just as an example it just threw the error with my Client.re file which contains only the following:

/* Create an InMemoryCache */
let inMemoryCache = ApolloInMemoryCache.createInMemoryCache();

/* Create an HTTP Link */
let httpLink =
  ApolloLinks.createHttpLink(
    ~uri="/graphql",
    ~credentials="same-origin",
    ~headers=
      Json.Encode.(
        object_([("Content-Type", Js.Json.string("application/json"))])
      ),
    (),
  );

let instance =
  ReasonApollo.createApolloClient(~link=httpLink, ~cache=inMemoryCache, ());

#6

I have the exact same problem. It will also give different filenames on every “save” of any random file. When it has walked through ~5 of these errors after ~5 “saves” it compiles successfully.
I’m also on version 3 of bs-platform, tried updating to patches and minors, didn’t solve the issue.
I also found this github issue with no fix as well :frowning: https://github.com/reasonml-community/bs-loader/issues/2

Was thinking about removing all bs-* dependencies and reinstalling.

Probably a coincidence, but I also use Apollo and have code similar to yours in my Client.re. (But the error isn’t always on Client.re)


#7

Thats really strange…

I tried everything today (reinstalling dependencies, checking version, use another bs-platform version, create new project and add old stuff one by one), i cannot figure out when/what goes wrong.

Btw. bsb -make-world completes everytime without any problems… :open_mouth:

This is where the build process “crashes”, but i dont think its very helpful:

3 verbose stack Error: client@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

Update

I have been using create-react-app with reason-scripts. I now migrated my project to bsb -init my-react-app -theme react- Method (https://reasonml.github.io/reason-react/docs/en/installation.html). Its working way better and faster now. i dont think it is a create-react-app issue in general… But maybe it will help you to @happylinks


#8

That fixed my problem as well! Thanks for the tip :smiley:

Wondering what causes this in react-scripts :thinking:


#9

This is a known issue in reason-scripts for a while now :confused: I’ve never been able to get a consistent reproducible case of it, but it’s just unfortunately bad.

As far as the “Array.map” thing, that’s another weird case.