Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

TTD Mac OS Sierra using Visual Studio Code #208

Open
ghost opened this issue Apr 4, 2017 · 11 comments
Open

TTD Mac OS Sierra using Visual Studio Code #208

ghost opened this issue Apr 4, 2017 · 11 comments
Assignees

Comments

@ghost
Copy link

ghost commented Apr 4, 2017

  • Version: v8.0.0-nightly2017040425ca0d9eb8
  • Platform: Mac OS
  • Subsystem: Sierra 10.12.3

Hi,

I have noticed an issue on Mac OS Sierra when using the time travel debugging.

I am using the test framework mocha.

When running my test I use the following command line:

➜  widget-counte node ./node_modules/mocha/bin/_mocha --record --opts test/config/mocha.opts test/components/Root.spec.js

The output:

Recording is enabled (but not yet started)...


Recording started (after main module loaded)...
  widget-counter -> root component
%cprevious state color: #9e9e9e; font-weight: bold; { counter: { value: 5 }, color: { value: '#000000' } }
%caction color: #33c3f0; font-weight: bold; { type: '__FRINT_INIT__' }
%ccurrent state color: #4cAf50; font-weight: bold; { counter: { value: 5 }, color: { value: '#000000' } }
    1) render


  0 passing (494ms)
  1 failing

  1) widget-counter -> root component render:
     Error: It looks like you called `mount()` without a global document being loaded.
     at ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:89:7)
     at mount (node_modules/enzyme/build/mount.js:19:3)
     at Anonymous function (test/components/Root.spec.js:164:5)

    Write error trace to: /Users/JBaudin/Documents/workspace/frint-samples/kitchensink/widget-counter/node_modules/mocha/bin/_diagnosticTraces/emitOnExit_code-1

In VSC, I have the following configuration in my launch.json file:

{
      "type": "node",
      "request": "launch",
      "name": "Launch Program (Chakracore)",
      "program": "${workspaceRoot}/kitchensink/widget-counter/node_modules/mocha/bin/_mocha",
      "runtimeExecutable": "/Users/JBaudin/.nvm/versions/node/v8.0.2/bin/node",
      "stopOnEntry": true,
      "runtimeArgs": [
        "--debug",
        "--nolazy",
        "--replay-debug=/Users/JBaudin/Documents/workspace/frint-samples/kitchensink/widget-counter/node_modules/mocha/bin/_diagnosticTraces/emitOnExit_code-1",
        "--break-first"
      ],
      "args": [
        "--compilers",
        "js:babel-register",
        "${workspaceRoot}/kitchensink/widget-counter/test/components/Root.spec.js"
      ],
      "console": "internalConsole"
    },

When I run the configuration in VSC here the output in the terminal:

/Users/JBaudin/.nvm/versions/node/v8.0.2/bin/node --debug-brk=47631 --debug --nolazy --replay-debug=/Users/JBaudin/Documents/workspace/frint-samples/kitchensink/widget-counter/node_modules/mocha/bin/_diagnosticTraces/emitOnExit_code-12 --break-first kitchensink/widget-counter/node_modules/mocha/bin/_mocha --compilers js:babel-register /Users/JBaudin/Documents/workspace/frint-samples/kitchensink/widget-counter/test/components/Root.spec.js 
Starting replay/debug using log in /Users/JBaudin/Documents/workspace/frint-samples/kitchensink/widget-counter/node_modules/mocha/bin/_diagnosticTraces/emitOnExit_code-12
(node:67598) [DEP0062] DeprecationWarning: node --debug is deprecated. Please use node --inspect instead.
Debugger listening on 127.0.0.1:47631
TTD assert failed: We probably forgot to update the vtable with a tag we added.

I tried to run the same test using the mocha binary instead of _mocha.
I was able to use the TTD until the mocha script spawn _mocha.

The problem is that I cannot access my tests for debugging.

Here are the traces:
emitOnExit_code-1.zip

Here is the component I am testing: https://gist.github.com/jackTheRipper/c52a934ee68b753a80faf201d817d05d

Here is my test:
https://gist.github.com/jackTheRipper/40c0dd7aadc9bb63fa7611050c2d8aae

My guess is that the creation of a sub-process or a worker by the script is not handled that well by the --record flag.

If I use a configuration file (using the flag --opts) I have a segmentation fault.

Commands:

➜  widget-counter node -v       
v8.0.0-nightly2017040425ca0d9eb8
➜  widget-counter node --record ./node_modules/mocha/bin/_mocha --opts test/config/mocha.opts test/components/Root.spec.js 
Recording is enabled (but not yet started)...


Recording started (after main module loaded)...
TTD assert failed: Invalid -- JavascriptGeneratorFunction
[1]    67489 abort      node --record ./node_modules/mocha/bin/_mocha --opts test/config/mocha.opts 

I think the error is related to the bootstrap file.
Here is the opts file:

--colors
--compilers js:babel-register
--require ./test/config/bootstrap.js

Here the bootstrap file:

import React from 'react';
import { observe, streamProps } from 'frint-react';
import { Observable } from 'rxjs';
import { jsdom } from 'jsdom';

global['frint-react'] = require('frint-react');
global.React = React;
global.observe = observe;
global.streamProps = streamProps;
global.Observable = Observable;
global.document = jsdom('<html><body><div id="root"></div></body></html>');
global.window = global.document.defaultView;
@kfarnung
Copy link
Contributor

kfarnung commented Apr 4, 2017

@mrkmarron Can you take a look at this issue?

@mrkmarron
Copy link
Contributor

Hi and thanks for the detailed report.

From my investigation it looks like there are 2 issues.

  1. The first issue you report looks like a bug in the TTD code (with a tentative fix here). I did not have a chance to fully verify the fix on your code but I have built a macOS binary as a release here to use while we flow the code up into the nightlies.
  2. As you hypothesized the second issue is related to the bootstrap file which uses jsdom and jsdom uses ES6 generators. Our ES6 support is in progress and generators are one of the larger open items. I have opened an new issue in the ChakraCore repo to track this. This is likely to be a longer term item so, for now, I think you will need to try and work around this.

Thanks and please let me know if this unblocks you.

@kfarnung
Copy link
Contributor

@JackTheRipper Were you able to work around this issue?

@ghost
Copy link
Author

ghost commented Jun 15, 2017

Hi @kfarnung, it's pretty unstable: sometimes it works some other times it doesn't. But I think it's because I am using Babel.

We can close the issue.

@ghost
Copy link
Author

ghost commented Jun 28, 2017

@kfarnung : I performed a new test with the same scenario as the one I described with the last version you released (v9.0.0-nightly201706277c8ccf55a7).

Here is the error I have when running in record mode:

➜  app-counter node --record $(npm bin)/_mocha --opts test/config/mocha.opts test/components/Root.spec.js
Recording is enabled (but not yet started)...

Recording started (after main module loaded)...
TTD assert failed: Invalid -- JavascriptGeneratorFunction
[1]    55065 abort      node --record $(npm bin)/_mocha --opts test/config/mocha.opts

@kfarnung
Copy link
Contributor

@JackTheRipper This looks like chakra-core/ChakraCore#2789

@ghost
Copy link
Author

ghost commented Jun 29, 2017

Another issue with Mocha is that internally it spawns processes. Could it affect the record mode as well?

@digitalinfinity
Copy link
Contributor

Hmm, @kfarnung shouldn't #285 have fixed the issue around child processes that seems to be affecting @JackTheRipper when he's using mocha?

@kfarnung
Copy link
Contributor

Yup, that should have taken care of the spawning a new process issue. The one potential issue is that triggering a trace in the child process might be tricky (if it doesn't crash on its own). The traces should all have the PID in the file name now for identification.

@ghost
Copy link
Author

ghost commented Jun 29, 2017

Hi @digitalinfinity following our discussion today I will give a new try without JSDom.

I am using Babel as well for my tests. As far as I understood from what @mrkmarron said I might only face an issue with the source-maps.

The feature for supporting the JS generators is already tracked (it's what is causing the issue).

If it works then I will close the issue.

@digitalinfinity
Copy link
Contributor

Hi @JackTheRipper - did you get a chance to try this without JSDom?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants