chrisvxd / story2sketch

Convert Storybook into Sketch symbols 💎
Other
402 stars 32 forks source link

Exit cleanly on error #51

Open chrisvxd opened 5 years ago

chrisvxd commented 5 years ago

When encountering an error in the page, it causes the page to become undefined and subsequent attempts to run goto on the page to cause a lot of errors:

Error: Evaluation failed: TypeError: node.getBoundingClientRect is not a function
    at nodeTreeToSketchGroup (/Users/chrisvilla/Projects/story2sketch/lib/server/../browser/page2layers.bundle.js:1693:18)
    at Object.getSymbol (/Users/chrisvilla/Projects/story2sketch/lib/server/../browser/page2layers.bundle.js:2133:103)
    at <anonymous>:4:12
    at ExecutionContext.evaluateHandle (/Users/chrisvilla/Projects/story2sketch/node_modules/puppeteer/lib/ExecutionContext.js:58:15)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
TypeError: Cannot read property 'goto' of undefined
    at Story2sketch._callee5$ (/Users/chrisvilla/Projects/story2sketch/lib/server/Story2sketch.js:489:29)
    at tryCatch (/Users/chrisvilla/Projects/story2sketch/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/chrisvilla/Projects/story2sketch/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/chrisvilla/Projects/story2sketch/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/chrisvilla/Projects/story2sketch/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/chrisvilla/Projects/story2sketch/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (/Users/chrisvilla/Projects/story2sketch/node_modules/core-js/library/modules/_export.js:35:28)
    at Story2sketch.<anonymous> (/Users/chrisvilla/Projects/story2sketch/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Story2sketch.getSymbolsForStory (/Users/chrisvilla/Projects/story2sketch/lib/server/Story2sketch.js:601:23)

with the latter error repeating as many times as there are symbols remaining.

When encountering an error in a page, story2sketch should exit cleanly.

LanceALaughlin commented 4 years ago

@chrisvxd any information on this error? I'm getting it when trying to run sketch2story and not sure where to debug. Thanks!

chrisvxd commented 4 years ago

Hey @LanceALaughlin, it generally means that storybook isn't rendering correctly so story2sketch can't find the node on the page.

Can you confirm your storybook renders in the browser? If not, fix that first. Otherwise, feel free to share your story2sketch config.

carpiediem commented 1 year ago

I'm getting the same error. I think the root of the problem is the firstChild attribute in getSymbol(). If getSymbol() is called without querySelector defined in the options argument, it sets nodes = document.querySelector(querySelector).firstChild (note: this should be singular, node).

The trouble is that, depending on whitespace in the source HTML, that there may or may not be text nodes surrounding the component node that we actually want. firstElementChild would avoid that issue.