-
Notifications
You must be signed in to change notification settings - Fork 48
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
Wait for file triggering before file is finished writing #24
Comments
Just to make sure: are you having that error message with the latest version? Also, you can add an extra debugging line in // Start webpage rendering server
// (this module will be compiled by Webpack server-side build from './source/server.js')
const starter = require(server_bundle_path)
console.log('@@@@@@@@@@@@', require('fs').readFileSync(server_bundle_path, 'utf8')) And see what are the actual contents of the file. |
Ok I will try this. I do have the latest version I was typing the error from memory so not quite right. |
Ok here is what I got on my first try (looks like the file contents are a few blank lines?). I will try a few more times and see if I get a different result:
|
Hmm, really, two blank lines. console.log('@' + require('fs').readFileSync(server_bundle_path, 'utf8') + '@') To know for sure |
As for the solution, I could, for example, check for the file contents. |
Tried with the second console.log options, and got no contents: ("/Users/andrewdailey/Code/mortgagehipporeact/build/server/server.js" not found) |
Oh, that's better. So it's not blank, it's simply empty. That makes sense. Releasing the fix. |
Try the latest version and see if it works for you (in time) |
Ok great thanks! |
I reported this before at some point, but it's back and is happening more often now for my growing project. When I am compiling my project using 'npm run dev' I run into this error every few times I build:
[universal-webpack] Your server source file must export a function. Got '{}'
I find that if I add a 1 second timeout to 'wait for file.js' I get rid of the error:
I believe what is happening is while the file is writing, the filesystem will report that it exists. But then when the file is loaded via 'require', the contents are not fully written, so it fails and returns an empty {}. By putting in the 1 second delay, the file is able to finish writing.
An alternative solution would be to make server.js retry requiring 'starter' (after a delay) when it doesn't return a function. Let me know if you need further info.
The text was updated successfully, but these errors were encountered: