Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'split' of undefined #406

Closed
cepon opened this issue Jun 5, 2019 · 11 comments
Closed

Cannot read property 'split' of undefined #406

cepon opened this issue Jun 5, 2019 · 11 comments
Assignees
Projects

Comments

@cepon
Copy link

cepon commented Jun 5, 2019

Hello,
I was working on 2.12.12 and everything works, now I moved to 2.18.16 and afer few saves it stops working. When I undo changes it is ok, but every next change there is same error.

image

@TheJaredWilcurt
Copy link
Member

The error is coming from trying to act upon the data that comes back from reading your file when no data is coming back. This is something that I can improve, but ultimately that's just handling the error state better. It isn't going to help with your real issue, which is the file not being found.

I don't know why it is having issues finding the file sometimes and not others. My guess is that it is related to "Atomic saves". You could try stopping a project, changing the value of the slider in the settings, then starting it again.

Without being able to reproduce this I don't know why it's happening. I will mark this as a bug though, just so we can better handle error states.

@tiagoagre
Copy link

tiagoagre commented Sep 27, 2019

Hi.

I have the same issue only using Visual Studio, but when using Notepad++ or other editor, it compiles correctly.

When i stop and run the project, it always compile correctly in any editor.

Tried to set the "Atomic saves delay" to any value, it wont solve the issue.

Didint look any further in the code, but just placing a setTimeout on App.js processInputFolder function (line 61) will solve my issue.
Yet i know this is not a solution, but maybe the issue is regarding a small delay on saving a file on Visual Studio.

Using:
Windows 10 Pro 64bit
Visual Studio 1.38.1
XAMPP (the server files are served locally)

function processInputFolder (project, inputSubFolder) {
		
		
		setTimeout(function() {
			var inputFolder = project.inputFolder;
			
			if (inputSubFolder) {
				inputFolder = path.join(project.inputFolder, inputSubFolder);
			}
			// Grab all the files in the input folder and put them in an array
			ugui.helpers.readAFolder(inputFolder, function (contents) {
				// check each file and process it if it is sass or scss and doesn't start with an underscore
				for (var i = 0; i < contents.length; i++) {
					var folder = contents[i].isFolder;
					var currentName = contents[i].name;
					if (folder) {
						var subfolder = currentName;
						if (inputSubFolder) {
							subfolder = path.join(inputSubFolder, currentName);
						}
						processInputFolder(project, subfolder);
					// Skip all files that begin with an _ and Process all sass/scss files
					} else if (!currentName.startsWith('_') && (currentName.toLowerCase().endsWith('.sass') || currentName.toLowerCase().endsWith('.scss'))) {
						// Change from 'some-file.scss' to 'some-file'
						var fileName = currentName.slice(0, -5);
						// Change from 'some-file.scss' to '.scss'
						var extension = currentName.substring(currentName.length - 5, currentName.length);
						// send to be converted to css and spit out into the output folder
						convertToCSS(project, fileName, extension, inputSubFolder);
					}
				}
			});
		}, 100);
    }

@TheJaredWilcurt
Copy link
Member

Weird. Since I can't reproduce this I have no means to experiment with it, but I'm curious if this fix comes from the JS event loop and even setting a time out of 0 would still work, or if it is just part of the OS claiming a file is done being accessed earlier than it actually is. If it is the second then 100ms will alleviate the issue for most, but not all, or not in every case, since it would depend on hardware and system resources as to the amount of time it takes for a file to become accessible again.

Either way, binding the timeout duration to match the atomic slider would work, as it would always have a minimum delay of 0ms to cause the event loop to cycle, but could allow setting a 700 ms delay for those on slower machines.

@ImSeaWorld
Copy link

Same happens to me. Stopping and starting the watcher is the only way to process the sass.

Visual Studio Code: v1.38.1 (b37e54c98e1a74ba89e03073e5a3761284e3ffb0)
Operating System: Windows 10.0.18362 x64

@WaxMikhail
Copy link

WaxMikhail commented Dec 20, 2019

This is happening for me now too. When I start a project, it compiles fine, but then when I make changes after that it gives me an error in Dev Tools: "Uncaught TypeError: Cannot read property 'split' of undefined". If I stop it, then start again, it processes changes, but then gives the error again unless stopped. Happening across all my projects. I'm using Atom 1.42.0 on Windows 10.

@TheJaredWilcurt TheJaredWilcurt self-assigned this Dec 27, 2019
@TheJaredWilcurt TheJaredWilcurt added this to Done, Unreleased in Scout-App 2 Dec 27, 2019
@TheJaredWilcurt
Copy link
Member

Was finally able to reproduce the issue consistently. I've added in some better safety checking and a helpful warning message to clue people into bumping up their atomic save delay setting if they are encountering this (to hopefully reduce the amount of GitHub issues created around it).

This has been merged to master and will be in the next release of Scout-App.

@ImSeaWorld
Copy link

ImSeaWorld commented Jan 9, 2020

Will there be a on-off toggle all together? @TheJaredWilcurt

@TheJaredWilcurt
Copy link
Member

No, there is a slider that takes the delay from 0 to 700ms. So "0ms" delay would be "off".

@aness
Copy link

aness commented Mar 31, 2020

First of all Thanks a lot for this App I do love it ;).
I used to work with Atom and it does work like a charm. Recently I used Visual studio code and got the same error.
So maybe the issue is still not solved btw I am using Scout-App V2.18.16 .

Same Error same error Log . It works after I modified scout-files/_scripts/app.js and added a timout for that processInputFolder like @tiagoagre suggested.
Regards

@TheJaredWilcurt
Copy link
Member

The fix is in master, there has not been a release with the fix in it yet. You can run code from the master branch if this is blocking you, for now.

@aness
Copy link

aness commented Apr 1, 2020

Hi @TheJaredWilcurt Thank you very much for your reply. Everything working out after adding a timout for that processInputFolder, but sometimes you need to save the file 2 times to compile( which is not a big problem - maybe I need to play with that timout val!!).
Yeah I am looking forward to your next release, hope to see the fix integrated to it.
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Scout-App 2
Done, Unreleased
Development

No branches or pull requests

6 participants