dldl / sphinx-preview

Sphinx preview in Atom
MIT License
5 stars 4 forks source link

Uncaught TypeError: Cannot read property 'file' of undefined #5

Closed splashx closed 6 years ago

splashx commented 7 years ago

[Enter steps to reproduce:]

  1. As pointed on #4 because of Docker limitation, manually did:
    
    docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:1234:2375 bobrik/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock

export DOCKER_HOST=tcp://localhost:2375

docker pull dldl/sphinx-server:latest


2. open `rst` file and `ctrl+alt+o`

**Atom**: 1.16.0 x64
**Electron**: 1.3.13
**OS**: Mac OS X 10.12.4
**Thrown From**: [sphinx-preview](https://github.com/dldl/sphinx-preview) package 0.1.0

### Stack Trace

Uncaught TypeError: Cannot read property 'file' of undefined

At /Users/splash/.atom/packages/sphinx-preview/lib/sphinx-preview.js:131

TypeError: Cannot read property 'file' of undefined at Object.openBrowser (/packages/sphinx-preview/lib/sphinx-preview.js:131:58) at /packages/sphinx-preview/lib/sphinx-preview.js:31:14 at Object.callback (/packages/sphinx-preview/lib/sphinx-preview.js:112:13) at /packages/sphinx-preview/node_modules/dockerode/lib/container.js:289:12 at Modem.buildPayload (/packages/sphinx-preview/node_modules/docker-modem/lib/modem.js:255:7) at /packages/sphinx-preview/node_modules/docker-modem/lib/modem.js:214:14) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)


### Commands
 -5:56 command-palette:toggle (input.hidden-input)
 -5:54.5.0 core:confirm (input.hidden-input)
 -5:54.4.0 sphinx-preview:toggle (input.hidden-input)
 -5:44.8.0 command-palette:toggle (input.hidden-input)
 -5:42.7.0 core:select-all (input.hidden-input)
 -5:41.4.0 core:backspace (input.hidden-input)
 -5:40.4.0 core:confirm (input.hidden-input)

2x -5:40.4.0 sphinx-preview:toggle (input.hidden-input) 4x -5:01.1.0 core:copy (input.hidden-input) -4:58.1.0 sphinx-preview:toggle (input.hidden-input) 5x -4:55.4.0 core:copy (atom-notification.error.icon.icon-flame.native-key-bindings) -0:31.6.0 command-palette:toggle (input.hidden-input) -0:29.3.0 core:confirm (input.hidden-input) -0:29.3.0 sphinx-preview:toggle (input.hidden-input)


### Non-Core Packages

atom-jinja2 0.6.0 atom-rst-preview-docutils 1.0.0 block-comment-plus 0.4.0 browser-plus 0.0.87 fold-functions 0.5.0 git-plus 7.8.0 graphviz-preview 1.7.0 language-markdown 0.22.0 language-restructuredtext 1.1.0 language-sphinx 0.1.6 markdown-toc 0.4.2 pretty-json 1.6.3 sort-lines 0.14.0 sphinx-preview 0.1.0 Sublime-Style-Column-Selection 1.7.4 tabs-to-spaces 1.0.3 url-encode 0.5.0

quentinus95 commented 7 years ago

The issue has been reproduced and a fix should be deployed ASAP.

quentinus95 commented 7 years ago

A fix has just been deployed, it should resolve the issue.

Please note that you don't need to use the workaround for the docker.sock file (it was a misconfiguration on sphinx-preview's side).

Please also note that you need to run sphinx-preview on an Atom instance only opened on your Sphinx project (it will fail if you have several project folders opened on the same Atom instance).

Finally, if the project does not refresh on change, please check if configuring a sphinx-server.yml configuration file at your project root fixes the issue (see https://github.com/dldl/sphinx-server).