Uncaught TypeError: Cannot read property 'length' of undefined
See original GitHub issue[Enter steps to reproduce below:]
- …
- …
Atom Version: 1.7.3 System: Mac OS X 10.11.4 Thrown From: Remote-FTP package, v0.8.1
Stack Trace
Uncaught TypeError: Cannot read property ‘length’ of undefined
At buffer.js:554
TypeError: Cannot read property 'length' of undefined
at Buffer.write (buffer.js:554:13)
at SFTPStream.stat (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/sftp.js:1599:7)
at SFTPWrapper.stat (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/lib/SFTPWrapper.js:87:23)
at /Users/Ingmar/.atom/packages/Remote-FTP/lib/connectors/sftp.js:154:18
at state.requests.(anonymous function).cb (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/sftp.js:1885:16)
at SFTPStream._transform (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/sftp.js:387:17)
at SFTPStream.Transform._read (_stream_transform.js:167:10)
at SFTPStream._read (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/sftp.js:170:15)
at SFTPStream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:292:12)
at writeOrBuffer (_stream_writable.js:278:5)
at SFTPStream.Writable.write (_stream_writable.js:207:11)
at Channel.ondata (_stream_readable.js:528:20)
at emitOne (events.js:77:13)
at Channel.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Channel.Readable.push (_stream_readable.js:110:10)
at SSH2Stream.<anonymous> (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/lib/Channel.js:146:15)
at emitOne (events.js:77:13)
at SSH2Stream.emit (events.js:169:7)
at parsePacket (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:3163:10)
at SSH2Stream._transform (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:551:13)
at SSH2Stream.Transform._read (_stream_transform.js:167:10)
at SSH2Stream._read (/Users/Ingmar/.atom/packages/Remote-FTP/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:212: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:528:20)
at emitOne (events.js:77:13)
Commands
-1:29.1.0 core:paste (atom-text-editor.editor.is-focused)
-1:28.7.0 core:move-up (atom-text-editor.editor.is-focused)
-1:28.4.0 core:move-right (atom-text-editor.editor.is-focused)
2x -1:28.2.0 core:move-up (atom-text-editor.editor.is-focused)
2x -1:27 core:select-down (atom-text-editor.editor.is-focused)
-1:26.6.0 core:backspace (atom-text-editor.editor.is-focused)
-1:26.4.0 core:save (atom-text-editor.editor.is-focused)
-1:16.8.0 core:move-down (atom-text-editor.editor.is-focused)
-1:16.2.0 editor:toggle-line-comments (atom-text-editor.editor.is-focused)
-1:15.9.0 core:move-down (atom-text-editor.editor.is-focused)
2x -1:15.5.0 core:select-down (atom-text-editor.editor.is-focused)
-1:14.8.0 editor:toggle-line-comments (atom-text-editor.editor.is-focused)
-1:14.5.0 core:save (atom-text-editor.editor.is-focused)
-1:03.2.0 remote-ftp:disconnect (atom-text-editor.editor.is-focused)
-0:18.5.0 remote-ftp:sync-with-remote (div.header.list-item)
-0:13.1.0 remote-ftp:connect (ol.ftptree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
Config
{
"core": {}
}
Installed Packages
# User
Remote-FTP, v0.8.1
# Dev
No dev packages
Issue Analytics
- State:
- Created 7 years ago
- Comments:9
Top Results From Across the Web
Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >Cannot read properties of undefined (reading 'length') - TrackJS
This message indicates that our code expects to have an object with a length property, but that object was not present. length is...
Read more >TypeError: Cannot read property 'length' of Undefined in JS
The "Cannot read property 'length' of undefined" error occurs when accessing the length property on an undefined value. To solve the error, make...
Read more >Typeerror: Cannot Read Property 'length' of Undefined
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can...
Read more >[SOLVED] Cannot Read Property 'length' of Undefined in JS
To fix the “cannot read property 'length' of undefined” error, perform an undefined check on the variable before accessing the length property ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error is located here: https://github.com/icetee/remote-ftp/blob/master/lib/client.js#L525
In my case,
self.info.remote
was blank (as the stack trace implies) which is why this line fails. However, this method takes inremote
as well which is the absolute path to the file you’re trying to download, for example:/var/www/test.php
.The fix for users now is to include the
remote
in the config and set it to/
or something else. For the case of fixing the code, there is a check normally that’s supposed to fix this issue, but it doesn’t seem to happen.It’s odd because the code that I have in the plugin isn’t shown here on the repo, at least not in the master branch. The code tries to default remote to
/
in order to fix this problem, but it doesn’t seem to work at all.Regardless, this code doesn’t set
self.info.remote
if it isn’t found either. The code in question I will post here since I don’t know what branch it’s supposed to be in:A simple solution would be to also set the
self.info.remote
here to prevent situation like this issue to come up.For those that come upon this error before a fix is provided, just add
remote
into your config and it should work fine.[Enter steps to reproduce:]
Atom: 1.33.1 x64 Electron: 2.0.16 OS: Windows 8.1 Thrown From: remote-ftp package 2.2.2
Stack Trace
Uncaught TypeError: Cannot read property ‘length’ of undefined
Commands
Non-Core Packages