amoussard / sftp-deployment

Spend less time managing file transfers and more time coding. SFTP support for Atom.io to send and receive files directly in your server.
MIT License
76 stars 44 forks source link

Uncaught TypeError: Cannot read property 'on' of undefined #80

Open Jaballadares opened 8 years ago

Jaballadares commented 8 years ago

[Enter steps to reproduce below:]

  1. Right click on directory
  2. Upload Selection

Atom Version: 1.0.16 System: Mac OS X 10.10.5 Thrown From: SFTP-deployment package, v1.0.2

Stack Trace

Uncaught TypeError: Cannot read property 'on' of undefined

At /Users/jballadares/.atom/packages/SFTP-deployment/lib/connections/SftpConnection.js:66

TypeError: Cannot read property 'on' of undefined
  at /Users/jballadares/.atom/packages/SFTP-deployment/lib/connections/SftpConnection.js:66:23
  at /Users/jballadares/.atom/packages/SFTP-deployment/node_modules/ssh2/lib/client.js:603:14
  at SSH2Stream.<anonymous> (/Users/jballadares/.atom/packages/SFTP-deployment/node_modules/ssh2/lib/client.js:1045:5)
  at SSH2Stream.g (events.js:260:16)
  at emitOne (events.js:77:13)
  at SSH2Stream.emit (events.js:169:7)
  at parsePacket (/Users/jballadares/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:3428:10)
  at SSH2Stream._transform (/Users/jballadares/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:555:13)
  at SSH2Stream.Transform._read [as __read] (_stream_transform.js:167:10)
  at SSH2Stream._read (/Users/jballadares/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:213:15)
  at SSH2Stream.Transform._write (_stream_transform.js:155:12)
  at doWrite (_stream_writable.js:291:12)
  at writeOrBuffer (_stream_writable.js:277:5)
  at SSH2Stream.Writable.write (_stream_writable.js:206:11)
  at Socket.ondata (_stream_readable.js:521:20)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:169:7)
  at readableAddChunk (_stream_readable.js:146:16)
  at Socket.Readable.push (_stream_readable.js:110:10)
  at TCP.onread (net.js:520:20)

Commands

     -4:28.5.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -4:26.5.0 sftp-deployment:uploadCurrentFile (atom-text-editor.editor)
     -2:59.6.0 emmet:toggle-comment (atom-text-editor.editor.is-focused)
     -2:59.6.0 editor:toggle-line-comments (atom-text-editor.editor.is-focused)
     -2:59.1.0 core:save (atom-text-editor.editor.is-focused)
     -2:58 command-palette:toggle (atom-text-editor.editor.is-focused)
     -2:56.2.0 sftp-deployment:uploadCurrentFile (atom-text-editor.editor)
     -1:58.3.0 emmet:insert-formatted-line-break-only (atom-text-editor.editor.is-focused)
     -1:58.3.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:54.2.0 emmet:insert-formatted-line-break-only (atom-text-editor.editor.is-focused)
     -0:54.2.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:52.2.0 emmet:insert-formatted-line-break-only (atom-text-editor.editor.is-focused)
     -0:52.2.0 editor:newline (atom-text-editor.editor.is-focused)
  3x -0:50.5.0 core:backspace (atom-text-editor.editor.is-focused.autocomplete-active)
     -0:47.4.0 core:save (atom-text-editor.editor.is-focused)
     -0:06.8.0 tool-panel:unfocus (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)

Config

{
  "core": {
    "themes": [
      "atom-light-ui",
      "atom-material-syntax"
    ],
    "disabledPackages": [
      "wrap-guide",
      "eslint",
      "linter-eslint",
      "atom-jshint",
      "atom-jade",
      "language-javascript-semantic",
      "linter-jshint"
    ],
    "audioBeep": false
  }
}

Installed Packages

# User
SFTP-deployment, v1.0.2
atom-beautify, v0.28.12
atom-jsfmt, v0.8.3
atom-material-syntax, v0.2.4
autocomplete-paths, v1.0.2
colorful-json, v1.0.0
emmet, v2.3.12
foldingtext-for-atom, v0.9.0
linter, v1.5.1
php-cs-fixer, v2.4.0
pigments, v0.14.0
pretty-json, v0.4.1
react, v0.12.9
seti-icons, v0.4.5

# Dev
No dev packages
sbarnekow commented 8 years ago

I'm hitting the same error! cc @amoussard

[Enter steps to reproduce below:]

  1. From the home directory, enter config to deployment-config.json
  2. Make some changes, "Upload open files"

Atom Version: 1.0.19 System: Mac OS X 10.10.2 Thrown From: SFTP-deployment package, v1.0.2

Stack Trace

Uncaught TypeError: Cannot read property 'on' of undefined

At /Users/sarahbarnekow/.atom/packages/SFTP-deployment/lib/connections/SftpConnection.js:66

TypeError: Cannot read property 'on' of undefined
    at /Users/sarahbarnekow/.atom/packages/SFTP-deployment/lib/connections/SftpConnection.js:66:23
    at /Users/sarahbarnekow/.atom/packages/SFTP-deployment/node_modules/ssh2/lib/client.js:1228:14
    at SSH2Stream.<anonymous> (/Users/sarahbarnekow/.atom/packages/SFTP-deployment/node_modules/ssh2/lib/Channel.js:179:24)
    at emitNone (events.js:67:13)
    at SSH2Stream.emit (events.js:166:7)
    at parsePacket (/Users/sarahbarnekow/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:3230:10)
    at SSH2Stream._transform (/Users/sarahbarnekow/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:555:13)
    at SSH2Stream.Transform._read [as __read] (_stream_transform.js:167:10)
    at SSH2Stream._read (/Users/sarahbarnekow/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:213:15)
    at SSH2Stream.Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:291:12)
    at writeOrBuffer (_stream_writable.js:277:5)
    at SSH2Stream.Writable.write (_stream_writable.js:206:11)
    at Socket.ondata (_stream_readable.js:521:20)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)

Commands

     -3:45.9.0 fuzzy-finder:toggle-file-finder (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
 18x -3:44.1.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -3:37 command-palette:toggle (atom-text-editor.editor.mini.is-focused)
     -3:34 core:confirm (atom-text-editor.editor.mini.is-focused)
     -3:33.8.0 sftp-deployment:mapToRemote (atom-text-editor.editor.mini)
  3x -3:22.3.0 core:paste (atom-text-editor.editor.is-focused)
  8x -3:07.5.0 core:backspace (atom-text-editor.editor.is-focused)
  5x -2:56.2.0 core:save (atom-text-editor.editor.is-focused)
     -2:05.4.0 sftp-deployment:uploadCurrentFile (atom-text-editor.editor.is-focused)
     -0:16 core:save (atom-notification.fatal.icon.icon-bug.native-key-bindings.has-detail.has-close.has-stack)

Config

{
  "core": {},
  "SFTP-deployment": {}
}

Installed Packages

# User
SFTP-deployment, v1.0.2
color-picker, v2.0.9
linter-reek, v2.0.0
pigments, v0.8.2

# Dev
No dev packages
davidchoy commented 8 years ago

(me too w/ "Upload open files")

JeromeDane commented 8 years ago

[Enter steps to reproduce below:]

  1. Right click on file
  2. Select upload

or

  1. Turn on auto-upload in configuration
  2. Make a file change

Atom Version: 1.5.3 System: Mac OS X 10.11.3 Thrown From: SFTP-deployment package, v1.0.2

Stack Trace

Uncaught TypeError: Cannot read property 'on' of undefined

At /Users/jeromedane/.atom/packages/SFTP-deployment/lib/connections/SftpConnection.js:66

TypeError: Cannot read property 'on' of undefined
    at /Users/jeromedane/.atom/packages/SFTP-deployment/lib/connections/SftpConnection.js:66:23
    at /Users/jeromedane/.atom/packages/SFTP-deployment/node_modules/ssh2/lib/client.js:1229:14
    at SSH2Stream.<anonymous> (/Users/jeromedane/.atom/packages/SFTP-deployment/node_modules/ssh2/lib/Channel.js:179:24)
    at emitNone (events.js:67:13)
    at SSH2Stream.emit (events.js:166:7)
    at parsePacket (/Users/jeromedane/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:3225:10)
    at SSH2Stream._transform (/Users/jeromedane/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:552:13)
    at SSH2Stream.Transform._read (_stream_transform.js:167:10)
    at SSH2Stream._read (/Users/jeromedane/.atom/packages/SFTP-deployment/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:213:15)
    at SSH2Stream.Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:292:12)
    at writeOrBuffer (_stream_writable.js:278:5)
    at SSH2Stream.Writable.write (_stream_writable.js:207:11)
    at Socket.ondata (_stream_readable.js:525:20)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at TCP.onread (net.js:523:20)

Commands

  5x -0:04.3.0 core:move-down (atom-text-editor.editor.is-focused)
     -0:03.7.0 core:move-up (atom-text-editor.editor.is-focused)
     -0:03.2.0 editor:move-to-first-character-of-line (atom-text-editor.editor.is-focused)
     -0:02.9.0 snippets:next-tab-stop (atom-text-editor.editor.is-focused)
     -0:02.9.0 snippets:expand (atom-text-editor.editor.is-focused)
     -0:02.8.0 editor:indent (atom-text-editor.editor.is-focused)
     -0:02.0 core:save (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "atom-ternjs"
    ],
    "packagesWithKeymapsDisabled": [
      "split-diff"
    ],
    "projectHome": "/Users/jeromedane/repos",
    "themes": [
      "seti-ui",
      "monokai-seti"
    ]
  }
}

Installed Packages

# User
SFTP-deployment, v1.0.2
atomatigit, v1.5.5
color-picker, v2.1.1
highlight-selected, v0.11.2
language-diff, v0.4.0
language-javascript-jsx, v0.3.7
linter, v1.11.3
linter-jscs, v3.4.5
linter-jshint, v1.3.1
minimap, v4.19.0
minimap-highlight-selected, v4.3.1
monokai-seti, v0.7.0
open-recent, v5.0.0
project-manager, v2.7.6
remote-edit, v1.8.24
seti-icons, v0.4.5
seti-ui, v0.8.1

# Dev
No dev packages
amoussard commented 8 years ago

Hi all,

I will fix this in the next release.

Thank you for your feedback.

mangosing commented 8 years ago

Has anyone found a solution for this problem? I have recently switched from Sublime to Atom and in setting this up with all the same info I got this error. If it helps I am connecting to wpengine.com and my coworker got it working on bluehost.com, thanks for all the help.

chon27 commented 8 years ago

I have got this error just after of install 'pigments' package (0.31.0). I just reset Atom and the error has cleared for me.

rardoz commented 8 years ago

Figured it out. If you go to ~/.atom/packages/SFTP-deployment/lib/connections/SftpConnections.js and replace linkes 54-79 with the following code all will work. The issue is its trying to create directories that already exists which causes a promise rejection. When you fix the bug just check to see if the directory exists first before calling the createRemoteDirectory function. The fix below is nasty and I don't have time to do it right. It works good enough for me though. (DONT FORGET TO RESTART ATOM AFTER THE CHANGE!)

SftpConnection.prototype.createRemoteDirectory = function(directoryPath) {
    var deferred = Promise.pending();

    try {
        var success = this.connection.exec(
            'mkdir -p ' + directoryPath,
            function (err, stream) {
                if (err) {
                    //deferred.reject(new RemoteDirectoryCreationErrorException(directoryPath));
                    return deferred.resolve(directoryPath);
                }
                stream.on('close', function() {
                    deferred.resolve(directoryPath);
                });
                stream.stderr.on('data', function(data) {
                    deferred.reject(new RemoteDirectoryCreationErrorException(directoryPath));
                });
            }
        );
    } catch(e) {
        deferred.reject(e);
    }

    return deferred.promise;
}
hightowerc87 commented 4 years ago

Figured it out. If you go to ~/.atom/packages/SFTP-deployment/lib/connections/SftpConnections.js and replace linkes 54-79 with the following code all will work. The issue is its trying to create directories that already exists which causes a promise rejection. When you fix the bug just check to see if the directory exists first before calling the createRemoteDirectory function. The fix below is nasty and I don't have time to do it right. It works good enough for me though. (DONT FORGET TO RESTART ATOM AFTER THE CHANGE!)

SftpConnection.prototype.createRemoteDirectory = function(directoryPath) {
    var deferred = Promise.pending();

    try {
        var success = this.connection.exec(
            'mkdir -p ' + directoryPath,
            function (err, stream) {
                if (err) {
                    //deferred.reject(new RemoteDirectoryCreationErrorException(directoryPath));
                    return deferred.resolve(directoryPath);
                }
                stream.on('close', function() {
                    deferred.resolve(directoryPath);
                });
                stream.stderr.on('data', function(data) {
                    deferred.reject(new RemoteDirectoryCreationErrorException(directoryPath));
                });
            }
        );
    } catch(e) {
        deferred.reject(e);
    }

    return deferred.promise;
}

Nailed it, thank you very much for that find