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

SourceMapConsumer error #45

Closed
beckend opened this issue Oct 28, 2016 · 25 comments
Closed

SourceMapConsumer error #45

beckend opened this issue Oct 28, 2016 · 25 comments
Assignees
Labels

Comments

@beckend
Copy link
Contributor

beckend commented Oct 28, 2016

Version 0.1.8 works fine, the repo master works.

Version >0.1.8 results in:

      at new SourceMapConsumer (node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:17:22)
      at mapSourcePosition (node_modules/source-map-support/source-map-support.js:164:14)
      at wrapCallSite (node_modules/source-map-support/source-map-support.js:331:20)
      at node_modules/source-map-support/source-map-support.js:366:26
      at Array.map (native)
      at Function.prepareStackTrace (node_modules/source-map-support/source-map-support.js:365:24)
      at process._tickCallback (internal/process/next_tick.js:103:7)

Error reproduce-able in repo branch, CI output.

Reproduce:

  • Clone
  • git checkout ts-jest-source-map-er-1
  • npm -g i jest-cli
  • npm i
  • jest --coverage --no-cache
@beckend
Copy link
Contributor Author

beckend commented Oct 28, 2016

Okay my local machine does not fail in master branch with [email protected] .
But the CI does...
I think this is due to that the CI always install latest "ts-jest".

Edit: I was right, explicit install of [email protected] before running test in CI fixed it.

@kulshekhar
Copy link
Owner

@beckend I'm trying this out now and can confirm this error

@kulshekhar
Copy link
Owner

@beckend are you sure this works with 0.1.8? I tried it and got a different error. At this point I'm not sure if the cause is ts-jest or something else

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

@kulshekhar I am pretty sure, what error are you getting?
You can see in the CI, I am doing "before_script" npm -g i gulp-cli jest-cli && npm -D i [email protected] .

@kulshekhar
Copy link
Owner

with 0.1.7, I got

 FAIL  src/__test__/combineEpics.spec.ts
  ● combineEpics › should pass along every argument arbitrarily

    SyntaxError

      at XMLHttpRequest.open (../../npm-global/lib/node_modules/jest-cli/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:458:15)
      at retrieveSourceMapURL (node_modules/ts-jest/index.js:119:9)
      at Array.<anonymous> (node_modules/ts-jest/index.js:150:26)
      at node_modules/ts-jest/index.js:48:24
      at mapSourcePosition (node_modules/ts-jest/index.js:180:21)
      at wrapCallSite (node_modules/ts-jest/index.js:347:20)
      at node_modules/ts-jest/index.js:382:26
      at Array.map (native)
      at Function.prepareStackTrace (node_modules/ts-jest/index.js:381:24)
      at Error.get stack [as stack] (native)

 FAIL  src/__test__/createEpicMiddleware.spec.ts
  ● createEpicMiddleware › should provide epics a stream of action$ in and the "lite" store

    SyntaxError

      at XMLHttpRequest.open (../../npm-global/lib/node_modules/jest-cli/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:458:15)
      at retrieveSourceMapURL (node_modules/ts-jest/index.js:119:9)
      at Array.<anonymous> (node_modules/ts-jest/index.js:150:26)
      at node_modules/ts-jest/index.js:48:24
      at mapSourcePosition (node_modules/ts-jest/index.js:180:21)
      at wrapCallSite (node_modules/ts-jest/index.js:347:20)
      at node_modules/ts-jest/index.js:382:26
      at Array.map (native)
      at Function.prepareStackTrace (node_modules/ts-jest/index.js:381:24)
      at Error.get stack [as stack] (native)

with 0.1.8, I got

 FAIL  src/__test__/createEpicMiddleware.spec.ts
  ● createEpicMiddleware › should provide epics a stream of action$ in and the "lite" store

    SyntaxError

      at XMLHttpRequest.open (../../npm-global/lib/node_modules/jest-cli/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:458:15)
      at retrieveSourceMapURL (node_modules/ts-jest/dist/index.js:86:13)
      at Array.<anonymous> (node_modules/ts-jest/dist/index.js:107:28)
      at node_modules/ts-jest/dist/index.js:29:30
      at mapSourcePosition (node_modules/ts-jest/dist/index.js:131:25)
      at wrapCallSite (node_modules/ts-jest/dist/index.js:262:24)
      at node_modules/ts-jest/dist/index.js:289:30
      at Array.map (native)
      at Function.prepareStackTrace (node_modules/ts-jest/dist/index.js:288:26)
      at Error.get stack [as stack] (native)

 FAIL  src/__test__/combineEpics.spec.ts
  ● combineEpics › should pass along every argument arbitrarily

    SyntaxError

      at XMLHttpRequest.open (../../npm-global/lib/node_modules/jest-cli/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:458:15)
      at retrieveSourceMapURL (node_modules/ts-jest/dist/index.js:86:13)
      at Array.<anonymous> (node_modules/ts-jest/dist/index.js:107:28)
      at node_modules/ts-jest/dist/index.js:29:30
      at mapSourcePosition (node_modules/ts-jest/dist/index.js:131:25)
      at wrapCallSite (node_modules/ts-jest/dist/index.js:262:24)
      at node_modules/ts-jest/dist/index.js:289:30
      at Array.map (native)
      at Function.prepareStackTrace (node_modules/ts-jest/dist/index.js:288:26)
      at Error.get stack [as stack] (native)

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

@kulshekhar
What about node -v and npm -v .
Travis uses [email protected] and [email protected] .
I use [email protected] and [email protected] .
I completely wiped node_modules and reinstalled to try to replicate your error and yea I still got my initial error with SourceMapConsumer .

So what I did is after npm i -> npm -D i [email protected] .
And then I reran the test, then it's fine, it's actually the same thing with the CI as i stated above.
It actually needs to explicitly install the 0.1.8 version after npm install.

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

@kulshekhar I did it three times.
It always fail without explicit install.
I always need to explicitly install [email protected] in order for it to pass after a npm i .
The CI is the same, it fails if I don't do the same.

@kulshekhar
Copy link
Owner

node -v v6.9.1
npm -v 3.10.8

I don't know much about sinon but it looks like it does some async stuff. Usually, async tests need to explicitly indicate that they are done by returning a promise or calling a callback. Have you tried something like that?

@kulshekhar
Copy link
Owner

I did a fresh clone,
changed the ts-jest dependency in package.json to 0.1.8
ran npm i
deleted the other 3 test files (except createEpicMiddleware)
ran jest --coverage
got the following output:

 FAIL  src/__test__/createEpicMiddleware.spec.ts
  ● createEpicMiddleware › should provide epics a stream of action$ in and the "lite" store

    SyntaxError

      at XMLHttpRequest.open (../../npm-global/lib/node_modules/jest-cli/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:458:15)
      at retrieveSourceMapURL (node_modules/ts-jest/dist/index.js:86:13)
      at Array.<anonymous> (node_modules/ts-jest/dist/index.js:107:28)
      at node_modules/ts-jest/dist/index.js:29:30
      at mapSourcePosition (node_modules/ts-jest/dist/index.js:131:25)
      at wrapCallSite (node_modules/ts-jest/dist/index.js:262:24)
      at node_modules/ts-jest/dist/index.js:289:30
      at Array.map (native)
      at Function.prepareStackTrace (node_modules/ts-jest/dist/index.js:288:26)
      at Error.get stack [as stack] (native)

  createEpicMiddleware
    ✕ should provide epics a stream of action$ in and the "lite" store (22ms)

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

So I will continue debugging this, it seems that you might be right about async test issue since it IS an async test.

@beckend beckend closed this as completed Oct 29, 2016
@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

@kulshekhar Thanks for the async test issue, it has been fixed and will always pass. Sorry about that.

I noted something about npm: It still installs 0.1.11 even if package.json says 0.1.8 . This applies to both my machne and CI.

So don't edit the package.json run npm -D i [email protected] .
You can try the same test again and you will probably pass if you follow instructions.

The main issue at hand still stands, when using >0.1.8 , SourceMapConsumer error will occur.

@kulshekhar
Copy link
Owner

I'm certain that I had 0.1.8 installed (I checked using npm ls --depth=0)

Nevertheless, I'll do this again. Please let me know if I should do something other than the following

git clone https://github.com/beckend/redux-observable-ts
cd redux-observable-ts
git checkout ts-jest-source-map-er-1
npm i
npm -D i [email protected]
jest --coverage

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

I wiped again and matched all your commands, but the last one I always use jest --coverage --no-cache .
Results:

  • Using ts-jest@latest , SourceMapConsumer error.
  • Using ``npm -D i [email protected]` passes.

@kulshekhar
Copy link
Owner

yeah, running it with --no-cache made the difference. I'm now getting what you're getting - no errors for 0.1.8 and the Unexpected token error for 0.1.10+

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

Sorry about the cache thing also I wasn't paying attention.

@kulshekhar
Copy link
Owner

I'm unable to determine the cause of this issue right now. I really don't know how Sinon behaves and I think that's key to debugging this.

How does it indicate completion? Is it using a promise or a callback?

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

@kulshekhar I did a quick debug: and this fixes it(but probably breaks something else):
node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:487 --- uncomment Error.prepareStackTrace = prepareStackTrace; .
And it passes...

I also tried to add "testResultsProcessor": "<rootDir>/node_modules/ts-jest/coverageprocessor.js" to package.json and I get proper remapping.

@beckend
Copy link
Contributor Author

beckend commented Oct 29, 2016

Going to sleep for today.

@kulshekhar
Copy link
Owner

That line is what makes the sourcemap translation work :)

Igmat added a commit that referenced this issue Nov 3, 2016
@Igmat
Copy link
Contributor

Igmat commented Nov 3, 2016

Actually problem is here in :

var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1);

Somehow in your code appears something that looks like source map url, but it isn't, or may be it is not in base64... Probably we have to get more deep on it.

@Igmat
Copy link
Contributor

Igmat commented Nov 3, 2016

Ok, I've found out. rxjs project has source maps, but as separate files, while our package assumes that all source maps are generated by it and included inline. Current fix actually returns null instead of reading that source map, probably we have to change this behavior.

@Igmat
Copy link
Contributor

Igmat commented Nov 3, 2016

Should be solved in ts-jest: 0.1.12. @beckend, feel free to reopen if it won't.

@Igmat Igmat closed this as completed Nov 3, 2016
@Igmat
Copy link
Contributor

Igmat commented Nov 3, 2016

Sorry guys, I was totally mistaken with our internal tests, so I reopen this issue and fix will be provided in ts-jest: 0.1.13 and 0.1.12 is unpublished from npm, because it's broken.

@Igmat Igmat reopened this Nov 3, 2016
@Igmat Igmat self-assigned this Nov 3, 2016
Igmat added a commit that referenced this issue Nov 4, 2016
@beckend
Copy link
Contributor Author

beckend commented Nov 7, 2016

Publish latest in npm so I can give it a spin?

@Igmat
Copy link
Contributor

Igmat commented Nov 7, 2016

@beckend, [email protected] is published. Try to use it. If it won't solve your problem just re-open this issue.

@Igmat Igmat closed this as completed Nov 7, 2016
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