Detox icon indicating copy to clipboard operation
Detox copied to clipboard

Lock is not acquired/owned by you

Open noomorph opened this issue 3 years ago • 8 comments

What happened?

We could see one worker (out of 4) not starting TeamCity due to this error:

[15:52:20]	[Running WOA Smoke iOS tests] 08:52:19.720 detox[33845] ERROR: Error: Lock is not acquired/owned by you
[15:52:20]	[Running WOA Smoke iOS tests]     at /Users/builder/work/node_modules/proper-lockfile/lib/lockfile.js:250:43
[15:52:20]	[Running WOA Smoke iOS tests]     at Object.newFs.<computed> [as realpath] (/Users/builder/work/node_modules/proper-lockfile/lib/adapter.js:20:13)
[15:52:20]	[Running WOA Smoke iOS tests]     at resolveCanonicalPath (/Users/builder/work/node_modules/proper-lockfile/lib/lockfile.js:21:16)
[15:52:20]	[Running WOA Smoke iOS tests]     at unlock (/Users/builder/work/node_modules/proper-lockfile/lib/lockfile.js:241:5)
[15:52:20]	[Running WOA Smoke iOS tests]     at /Users/builder/work/node_modules/proper-lockfile/lib/adapter.js:53:9
[15:52:20]	[Running WOA Smoke iOS tests]     at AsyncFunction.unlockSync (/Users/builder/work/node_modules/proper-lockfile/index.js:23:35)
[15:52:20]	[Running WOA Smoke iOS tests]     at ExclusiveLockfile._unlock (/Users/builder/work/node_modules/detox/src/utils/ExclusiveLockfile.js:138:15)
[15:52:20]	[Running WOA Smoke iOS tests]     at ExclusiveLockfile.exclusively (/Users/builder/work/node_modules/detox/src/utils/ExclusiveLockfile.js:43:18)
[15:52:20]	[Running WOA Smoke iOS tests]     at SimulatorAllocDriver.allocate (/Users/builder/work/node_modules/detox/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js:29:18)
[15:52:20]	[Running WOA Smoke iOS tests]     at traceCall (/Users/builder/work/node_modules/detox/src/utils/trace.js:41:20)

See on our TeamCity server:

/viewLog.html?buildId=133812009&buildTypeId=WixMobile_WixOneApp_WixOneAppParallel_OneApp07&tab=buildLog&_focus=58935#_state=58884

What was the expected behaviour?

It should have waited until the lock file gets released and then mind its own business. Definitely, it should not have thrown an exception, out of the blue.

Was it tested on latest Detox?

  • [X] I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

No, I won't help you reproduce this issue. Looks like it is a race condition. I'd suggest to examine the code and muse what can practically trigger this situation. Code inspection has a high chance to be helpful enough.

In what environment did this happen?

In our internal TeamCity.

Detox logs

Visit the build page.

Device logs

Visit the build page.

More data, please!

No response

noomorph avatar May 30 '22 10:05 noomorph

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

stale[bot] avatar Jul 01 '22 12:07 stale[bot]

I'm inclined to say that this will be resolved via project DAS but pinning this nonetheless because it is still an in-effect bug.

d4vidi avatar Jul 05 '22 11:07 d4vidi

@d4vidi

In an effort to reproduce a different bug, I seem to have also encountered this:

15:55:46.925 detox[90619] DEBUG: [EXEC_CMD, #1] /usr/bin/xcrun simctl create "iPhone 13-Detox" "com.apple.CoreSimulator.SimDeviceType.iPhone-13" "com.apple.CoreSimulator.SimRuntime.iOS-15-5"
15:55:47.341 detox[90620] TRACE: [EXEC_SUCCESS, #2] 
15:55:47.341 detox[90620] DEBUG: [EXEC_CMD, #3] /usr/bin/xcrun simctl bootstatus 72E2C79D-E868-4657-A649-D975F0F11DDA
15:55:49.620 detox[90621] TRACE: [EXEC_SUCCESS, #3] 
15:55:49.621 detox[90621] DEBUG: [EXEC_CMD, #4] /usr/bin/xcrun simctl bootstatus 800F2D93-F7ED-4FB6-842C-967AF05B5D49
15:56:26.768 detox[90619] TRACE: [EXEC_SUCCESS, #1] 7A46A38F-E302-40B4-BA8F-F5933C575C9B

15:56:28.616 detox[90619] ERROR: Error: Lock is not acquired/owned by you
    at /Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/proper-lockfile/lib/lockfile.js:250:43
    at Object.newFs.<computed> [as realpath] (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/proper-lockfile/lib/adapter.js:20:13)
    at resolveCanonicalPath (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/proper-lockfile/lib/lockfile.js:21:16)
    at unlock (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/proper-lockfile/lib/lockfile.js:241:5)
    at /Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/proper-lockfile/lib/adapter.js:53:9
    at AsyncFunction.unlockSync (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/proper-lockfile/index.js:23:35)
    at ExclusiveLockfile._unlock (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/detox/src/utils/ExclusiveLockfile.js:138:15)
    at ExclusiveLockfile.exclusively (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/detox/src/utils/ExclusiveLockfile.js:43:18)
    at SimulatorAllocDriver.allocate (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/detox/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js:29:18)
    at traceCall (/Users/runner/work/REDACTED/REDACTED/MembersNative/node_modules/detox/src/utils/trace.js:41:20)
15:56:31.092 detox[90619] TRACE: [ARTIFACTS_LIFECYCLE] artifactsManager.onBeforeCleanup()
15:56:31.749 detox[90619] DEBUG: [WSS_CLOSE] Detox server has been closed gracefully
FAIL e2e/InitCITests/worker2.initci.ts (50.43 s)
  ● It should start worker 2

    Environment setup failed. See the detailed error below.




  ● Test suite failed to run

    Unable to update lock within the stale threshold

      at ../../node_modules/proper-lockfile/lib/lockfile.js:109:21
      at Object.newFs.<computed> [as utimes] (../../node_modules/proper-lockfile/lib/adapter.js:20:13)
      at Timeout._onTimeout (../../node_modules/proper-lockfile/lib/lockfile.js:100:20)

  ● Test suite failed to run

    Lock is not acquired/owned by you

      at ../../node_modules/proper-lockfile/lib/lockfile.js:250:43
      at Object.newFs.<computed> [as realpath] (../../node_modules/proper-lockfile/lib/adapter.js:20:13)
      at resolveCanonicalPath (../../node_modules/proper-lockfile/lib/lockfile.js:21:16)
      at unlock (../../node_modules/proper-lockfile/lib/lockfile.js:241:5)
      at ../../node_modules/proper-lockfile/lib/adapter.js:53:9
      at AsyncFunction.unlockSync (../../node_modules/proper-lockfile/index.js:23:35)
      at ExclusiveLockfile._unlock (../../node_modules/detox/src/utils/ExclusiveLockfile.js:138:15)
      at ExclusiveLockfile.exclusively (../../node_modules/detox/src/utils/ExclusiveLockfile.js:43:18)
      at SimulatorAllocDriver.allocate (../../node_modules/detox/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js:29:18)
      at traceCall (../../node_modules/detox/src/utils/trace.js:41:20)

15:56:33.114 detox[90619] TRACE: [SESSION_TORN] tester exited session 7c01a882-09e7-0d6f-d288-78c3d97f06cb
15:58:06.509 detox[90620] TRACE: [EXEC_SUCCESS, #3] Monitoring boot status for iPhone 13 (72E2C79D-E868-4657-A649-D975F0F11DDA).

You said this will be resolved via "project DAS". Could you elaborate further on what that is and when we can expect it/how we may implement it?

zacharyweidenbach avatar Aug 30 '22 17:08 zacharyweidenbach

Project Device Allocation Server is a part of potential future-plans that we have for Detox. It's not for users to implement.

In any case, seems that the logs you have might be able to shed a light on where this error comes from. Could you provide logs from the very beginning of the Detox run?

d4vidi avatar Aug 30 '22 19:08 d4vidi

@d4vidi Here is the full log from the Detox run for that step 18_Initialize Detox Tests.txt

zacharyweidenbach avatar Aug 30 '22 19:08 zacharyweidenbach

@zacharyweidenbach may I ask why you run Detox with --keepLockFile true? Have you tried running without that arg?

d4vidi avatar Aug 31 '22 08:08 d4vidi

In any case, I would appreciate also rerunning Detox with the --record-timeline all argument, and sending over the resulting detox.trace.json file (i.e. under artifacts/).

d4vidi avatar Aug 31 '22 09:08 d4vidi

So, this error physically happens when lock file disappears earlier, and unlock() bites the dust. Still, it's interesting how this happens in our logic 🤔

noomorph avatar Nov 21 '23 10:11 noomorph