superlou / fountain-atom

Grammar and tools for the Fountain screenwriting syntax
MIT License
48 stars 15 forks source link

Uncaught TypeError: Cannot read property 'getGrammar' of undefined #82

Closed altanvh closed 5 years ago

altanvh commented 6 years ago

[Enter steps to reproduce:]

  1. ...Packages
  2. ...Fountain
  3. Show preview

Atom: 1.31.1 x64 Electron: 2.0.7 OS: Ubuntu 16.04.5 Thrown From: fountain package 0.8.1

Stack Trace

Uncaught TypeError: Cannot read property 'getGrammar' of undefined

At /home/haldun/.atom/packages/fountain/lib/fountain.coffee:210

TypeError: Cannot read property 'getGrammar' of undefined
    at Object.pdfPreview (/packages/fountain/lib/fountain.coffee:210:25)
    at /packages/fountain/lib/fountain.coffee:166:31)
    at CommandRegistry.handleCommandEvent (/snap/atom/200/usr/share/atom/resources/app/src/command-registry.js:384:49)
    at CommandRegistry.dispatch (/snap/atom/200/usr/share/atom/resources/app/src/command-registry.js:273:23)
    at AtomEnvironment.dispatchApplicationMenuCommand (/snap/atom/200/usr/share/atom/resources/app/src/atom-environment.js:1351:25)
    at EventEmitter.outerCallback (/snap/atom/200/usr/share/atom/resources/app/src/application-delegate.js:311:53)
    at emitThree (events.js:136:13)
    at EventEmitter.emit (events.js:217:7)

Commands

     -9:13.1.0 core:save-as (ul.list-inline.tab-bar.inset-panel)
     -7:52.8.0 fountain:export-PDF (ul.list-inline.tab-bar.inset-panel)
     -1:48.5.0 core:backspace (input.hidden-input)
     -1:43.7.0 core:save (input.hidden-input)
     -0:33.3.0 fountain:preview (div.pdf-view)

Non-Core Packages

fountain 0.8.1 
pdf-view 0.71.0 
superlou commented 6 years ago

I haven't been able to recreate this with 1.31.2 x64 with Linux Mint 18.3. Does it happen every time you follow those steps, or only sometimes?

jrbostic commented 6 years ago

I did notice that the editorOrActiveEditor code on line 206 is using an if/then control structure along with a "?". Not sure what impact the question mark has on evaluation.

superlou commented 6 years ago

@jrbostic The existential operator is a coffeescript bit of syntactic sugar for dealing with Javascript's multiple kinds of "not ready to use" variable.

jrbostic commented 6 years ago

@superlou Sure. But the additional cases that this would catch and return truthy for would probably not be appropriate. I'm not saying that this is definitely a problem in this case, but it is the only relevant piece of retrieval code that could cause the error described... If I read it right. Based on what I just read the only case this usage would return falsey for is if the variable didn't exist at all.

superlou commented 6 years ago

Good point. That getGrammar error seems really popular in Atom packages, and I initially thought there had been an API change (I was on 1.26 before updating). "Hopefully" this is happening to @altanvh consistently so we can check the state of the variables there.

altanvh commented 6 years ago

Hello,

I'm on ubuntu studio 16.04 Atom version 1.31.2 I tried now and I get the same answer her by Thanks alot for your helping :) Haldun.

[Enter steps to reproduce:]

  1. ...
  2. ...

    Atom: 1.31.2 x64 Electron: 2.0.7 OS: Ubuntu 16.04.5 Thrown From: fountain package 0.8.1

    Stack Trace

    Uncaught TypeError: Cannot read property 'getGrammar' of undefined

      At /home/haldun/.atom/packages/fountain/lib/fountain.coffee:210
    
      TypeError: Cannot read property 'getGrammar' of undefined
          at Object.pdfPreview
      (/packages/fountain/lib/fountain.coffee:210:25)
          at /packages/fountain/lib/fountain.coffee:166:31)
          at CommandRegistry.handleCommandEvent
    (/snap/atom/202/usr/share/atom/resources/app/src/command-registry.js:384:49)
          at CommandRegistry.dispatch
    (/snap/atom/202/usr/share/atom/resources/app/src/command-registry.js:273:23)
          at AtomEnvironment.dispatchApplicationMenuCommand
    (/snap/atom/202/usr/share/atom/resources/app/src/atom-environment.js:1351:25)
          at EventEmitter.outerCallback
    (/snap/atom/202/usr/share/atom/resources/app/src/application-delegate.js:311:53)
          at emitThree (events.js:136:13)
          at EventEmitter.emit (events.js:217:7)

    Commands

           -0:37.5.0 fountain:preview (atom-pane.pane.active)
  ### Non-Core Packages

  ```
  fountain 0.8.1 
  pdf-view 0.71.0 
  ```
belzecue commented 5 years ago

UPDATE: Restarted editor and no longer getting this error when exporting fountain file to PDF. Will update further if I can reproduce.


Got this same error on Windows 10 when attempting to export PDF. PDF previews fine in editor.

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.33.0 x64 Electron: 2.0.11 OS: Microsoft Windows 10 Pro Thrown From: fountain package 0.8.1

Stack Trace

Uncaught TypeError: Cannot read property 'getGrammar' of undefined

At C:\Users\[redacted]\.atom\packages\fountain\lib\fountain.coffee:227

TypeError: Cannot read property 'getGrammar' of undefined
    at Object.pdfExport (/packages/fountain/lib/fountain.coffee:227:25)
    at /packages/fountain/lib/fountain.coffee:167:34)
    at CommandRegistry.handleCommandEvent (~/AppData/Local/atom/app-1.33.0/resources/app/static/<embedded>:11:349858)
    at Object.didConfirmSelection (~/AppData/Local/atom/app-1.33.0/resources/app/static/<embedded>:11:693551)
    at SelectListView.confirmSelection (~/AppData/Local/atom/app-1.33.0/resources/app/static/<embedded>:11:858841)
    at SelectListView.didClickItem (~/AppData/Local/atom/app-1.33.0/resources/app/static/<embedded>:11:856783)
    at ListItemView.onclick (~/AppData/Local/atom/app-1.33.0/resources/app/static/<embedded>:11:855773)
    at ListItemView.didClick (~/AppData/Local/atom/app-1.33.0/resources/app/static/<embedded>:11:859861)

Commands

     -2:52.6.0 core:select-all (input.hidden-input)
     -2:52.1.0 core:paste (input.hidden-input)
     -2:50.2.0 core:save (input.hidden-input)
     -2:47.1.0 command-palette:toggle (input.hidden-input)
     -2:45.8.0 editor:consolidate-selections (input.hidden-input)
     -2:45.8.0 core:cancel (input.hidden-input)
     -2:44 fountain:preview (input.hidden-input)
     -1:31.4.0 command-palette:toggle (div.pdf-view)
     -1:28.3.0 fountain:export-PDF (div.pdf-view)

Non-Core Packages

fountain 0.8.1 
pdf-view 0.59.0 
superlou commented 5 years ago

Thanks for the update. I'm going to close, and we can reopen or create a new issue if this comes back.