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

File locking when recycling pool #10

Open
Daniel15 opened this issue Nov 17, 2015 · 4 comments
Open

File locking when recycling pool #10

Daniel15 opened this issue Nov 17, 2015 · 4 comments
Labels

Comments

@Daniel15
Copy link
Owner

Reported by @gregbty at reactjs/React.NET#181:

The process cannot access the file '...\www\js\bundles\server.js' because it is being used by another process.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
   at System.IO.File.ReadAllText(String path, Encoding encoding)
   at React.FileSystemBase.ReadAsString(String relativePath)
   at React.JavaScriptEngineFactory.LoadUserScripts(IJsEngine engine)
   at React.JavaScriptEngineFactory.InitialiseEngine(IJsEngine engine)
   at JSPool.JsPool.CreateEngine()
   at JSPool.JsPool.PopulateEngines()
   at JSPool.JsPool.Recycle()
   at JSPool.JsPool.<InitializeWatcher>b__10_0(Object sender, EventArgs args)
   at JSPool.FileWatcher.OnTimer(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()
@Daniel15
Copy link
Owner Author

I wonder if JSPool should avoid recycling the pool of JavaScript engines until none of the watched files are locked. Currently it debounces the recycle to handle the case where there's a few changes to the same file in a short period of time. The delay could be increased (currently it's 25ms) which would work around this issue, it's a pretty hacky fix though.

@Daniel15 Daniel15 added the bug label Nov 17, 2015
@bjornstromblom
Copy link

From what i can tell out of the blue i started getting this same error. Just updated to latest version and the bug persists. Any solution or tips?

@ArgonAlex
Copy link

ArgonAlex commented Aug 30, 2016

In my case I have a 4MB script (I don't know if size makes a difference) that results in the Initializer() function being called 3 times as it is being written to. The 1st time fails at reading my file, but the 2nd and 3rd times succeed. So at least in my case it seems that the 25ms debounce timeout was not enough.

@Daniel15
Copy link
Owner Author

Daniel15 commented Sep 4, 2016

So at least in my case it seems that the 25ms debounce timeout was not enough.

You could try increasing that timeout, building your own build of JSPool, and seeing whether that helps.

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

3 participants