-
Notifications
You must be signed in to change notification settings - Fork 107
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
Error on module part of learnyounode workshop #2068
Comments
Verification is failing on the step "Additional module file handles callback argument" - so it's testing your module file With your module expecting If you refactor your module to use a single |
Having modified my directory utils as mentioned above to just use 3 arguments function (directoryPath, fileExtension, cbLogger) {
directoryReader.readdir(directoryPath, function (error, files) {
if (!error)
return files.filter(function (fileName) {
return pathReader.extname(fileName).slice(1) === fileExtension;
}).map(function (fileName) {
cbLogger(null, fileName);
});
cbLogger(error);
});
}; I still get a variant of the same error
My caller does look like this var directory = require('./directory-utils.js')
var logInfo = function (error, fileName) {
if (error)
return console.error(error);
console.log(fileName);
};
directory(directoryPath, fileExtension, logInfo); |
Ah, that's a particularly confusing error message.
The exercise expects you to provide a module which reads the list of
filenames, filters them, and then calls the callback *once* with the array
of filtered filenames. Your module is calling the callback multiple times,
which comes as quite a surprise to the exercise verification code.
…On 12 Apr 2017 11:59 a.m., "Vikram" ***@***.***> wrote:
Having modified my directory utils as mentioned above to just use 3
arguments
function (directoryPath, fileExtension, cbLogger) {
directoryReader.readdir(directoryPath, function (error, files) {
if (!error)
return files.filter(function (fileName) {
return pathReader.extname(fileName).slice(1) === fileExtension;
}).map(function (fileName) {
cbLogger(null, fileName);
});
cbLogger(error);
});
};
I still get a variant of the same error
node_modules\learnyounode\node_modules\workshopper-exercise\exercise.js:188
processors[i].call(self, mode, function (err, pass) {
^
TypeError: Cannot read property 'call' of undefined
at next (\node_modules\learnyounode\node_modules\workshopper-exercise\exercise.js:188:18)
at \npm\node_modules\learnyounode\node_modules\workshopper-exercise\exercise.js:195:7
at callback (make_it_modular\verify.js:26:15)
at modFileError (make_it_modular\verify.js:31:5)
at \make_it_modular\verify.js:131:18
at c:\code\node-workshop\directory-utils.js:11:17
at Array.map (native)
at c:\code\node-workshop\directory-utils.js:10:16
at FSReqWrap.oncomplete (fs.js:123:15)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2068 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYxx2iaJhspR2di0wLOPP9rTOHxAx6jks5rvK6egaJpZM4M6AP2>
.
|
Thanks modifying th code to return the files rather than calling the logger within the map function helped and got me past the verification too albeit i did avoid the use of a forech loop as per the suggested by the final solution. Just wondering if the notes on the verification steps could be made a bit more clear to highlight this situaion? Otherewise happe for this to be closed. |
Hi vikmn,
array entry - processors[i].call) is the same one I have been discussing in the topic titled "Error when
exercises ought to be more robust than to crash in the face of what it seems is a common
now common (?) issue with that exercise (actually with the code that analyzes the potential solution) to -- [EDIT: To add some newlines - even though it looked fine when I entered it, each paragraph was one long |
I tried reproducing this variety of problem on my machine and I saw output like this:
While I agree that the error text is not helpful, the verification messages stating "Your additional module file [mod.js] did not return an Array object as the second argument of the callback" are attempting to point the student in the right direction. Can I ask if either of you saw that message? If not, I'd be worried that this verification is not catching the case it was intended for. As far as errors from the exercise verification and bugs go, I can only point you to [edited to add] I am not a maintainer or contributor to |
Hi David,
I’ve pasted the output of my verification step to this email below (it was also in my original message to start the thread at the forum). In my case it never got so far as to display anything about the function not returning an array. The last thing it outputs before the stack dump is the “Additional module file handles callback argument” message. I never see anything about it checking if the module returns an array. Had I gotten that output, along with the fact that it failed that check (as your output shows), that would have been more helpful to me in troubleshooting where I’d failed. As it was I didn’t even realize that I needed to return an array, much less that it was checking for that.
Also, I think the way your output has the checkmarks on the line with the criteria it checked is better than the way I’m getting the same information, with the checkmark on a line by itself. In my outputs I couldn’t tell if the checks were pertaining to the thing before them in the output, of if they correlated to the thing that followed them. For example (abbreviated output for demonstrative purpose… I’m not sure how to type the check mark – so <check>):
/*********************** MY “output” ***********************/
Actual output Expected output
Blah.md Blah.md
<check>
Submission results match expected
<check>
Additional module file handles callback argument
C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\learnyounode\node_modul
es\workshopper-exercise\exercise.js:188
processors[i].call(self, mode, function (err, pass) {
^
When seen like this, does the first <check> apply to what came before (the actual and expected outputs), or the line after the check (that the actual matched the expected)? My brain seems to want to see messages that explain what is about to be tested, then a check mark printed when that test passes (or, alternately, something else, such as your “X-mark”, printed when it fails). Instead it prints the check mark followed by the explanation of what test just passed. The problem with that is that if the test fails and you get the stack dump, you end up not even knowing what test was in progress when it crashed. However for some reason your output does show that the test failed before doing the stack dump.
So… No, in my case I didn’t see that it was trying to check if my module returned an array when the analysis program crashed (as you can see below). I had the impression from reading the other guys topic that he didn’t either. I would say it tried to access the call property of an element of the processors[] array that isn’t there (is undefined), and crashed before it could detect that my module didn’t return an array. So I’d agree with your worry, it isn’t catching the case it intends to because it crashes before it can catch it.
I’m wondering if, in my case (possibly both cases?) there is either a difference in version of the learnyounode package, or if the fact that I’m running things from a command prompt window (in Win 7) affects what I’m getting (or not getting) as output.
Clearly when you are running the program (in whatever shell program or browser you are using) it does produce the check marks on the same line as the item it is declaring it has checked off (unlike my output). Also I’m having issues with the colorizing of code lines because for some of the colorized output (apparently at least numeric literals) the colorized characters are colored the same color as the background, and so those characters disappear. That’s really bad, but also some of the other colors chosen for other aspects of the code don’t provide enough contrast to the background color and thus are quite difficult to read. You can see at least that there is something there, but its difficult to read it.
So… perhaps you might suggest another environment where I ought to be running this instead of from a Command Prompt window? I think I’ve tried a bash shell in a Cygwin environment, but had difficulty with that.
Also, perhaps another potential difference – I seem to have an older version. When I enter “learnyounode update” it indicates I have 3.5.8 and that it wants to install 3.5.10 using “npm install learnyounode@latest –g” Then it promptly crashes:
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
C:\Greg\WebDev\JavaScript\NodeSchool\learnyounode>
So first would the newer 3.5.10 version of learnyounode perhaps help (such as maybe producing the additional output you get)? If so (or regardless anyway), do you know how I could overcome this error and get my update to install the new version?
Anyway, thanks for looking into this. My verification output, along with the version of code that it was verifying at the time (which fails the “returns an array” criteria) is below…
Thanks,
--
Greg Youngdahl
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
C:\Greg\WebDev\JavaScript\NodeSchool\learnyounode>learnyounode verify program.js
# LEARN YOU THE NODE.JS FOR MUCH WIN!
## MAKE IT MODULAR (Exercise 6 of 13)
Your submission results compared to the expected:
ACTUAL EXPECTED
────────────────────────────────────────────────────────────────────────────────
"CHANGELOG.md" == "CHANGELOG.md"
"LICENCE.md" == "LICENCE.md"
"README.md" == "README.md"
"" == ""
────────────────────────────────────────────────────────────────────────────────
✓
Submission results match expected
✓
Additional module file exports a single function
✓
Additional module file exports a function that takes 3 arguments
✓
Additional module file handles errors properly
✓
Additional module file handles callback argument
C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\learnyounode\node_modul
es\workshopper-exercise\exercise.js:188
processors[i].call(self, mode, function (err, pass) {
^
TypeError: Cannot read property 'call' of undefined
at next (C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\learnyouno
de\node_modules\workshopper-exercise\exercise.js:188:18)
at C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\learnyounode\nod
e_modules\workshopper-exercise\exercise.js:195:7
at callback (C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\learny
ounode\exercises\make_it_modular\verify.js:26:15)
at modFileError (C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\le
arnyounode\exercises\make_it_modular\verify.js:31:5)
at C:\Users\Greg Youngdahl\AppData\Roaming\npm\node_modules\learnyounode\exe
rcises\make_it_modular\verify.js:130:18
at C:\Greg\WebDev\JavaScript\NodeSchool\learnyounode\myCallback.js:16:25
at FSReqWrap.oncomplete (fs.js:123:15)
C:\Greg\WebDev\JavaScript\NodeSchool\learnyounode>
############################ My Code ############################
program.js
var fs = require('fs'),
path = require('path'),
myCallback = require('./myCallback.js');
var pth = process.argv[2];
var ext = process.argv[3];
myCallback( pth, ext, function( err, data ) {
if( err ) console.log( err );
else console.log( data );
});
myCallback.js
var fs = require('fs');
var path = require('path');
module.exports =
function dirFilter( dirName, extension, callback )
{
fs.readdir( dirName, function( err, files ) {
if( err ) { return callback( err ); }
for( var i = 0; i < files.length; i++ )
{
if( path.extname( files[i] ) == '.' + extension )
{
callback( null, files[i] );
}
}
});
}
From: David McMullin [mailto:notifications@github.com]
Sent: Thursday, April 13, 2017 7:11 PM
To: nodeschool/discussions
Cc: Greg Youngdahl; Comment
Subject: Re: [nodeschool/discussions] Error on module part of learnyounode workshop (#2068)
I tried reproducing this variety of problem on my machine and I saw output like this:
Your submission results compared to the expected:
ACTUAL EXPECTED
────────────────────────────────────────────────────────────────────────────────
"CHANGELOG.md" == "CHANGELOG.md"
"LICENCE.md" == "LICENCE.md"
"README.md" == "README.md"
"" == ""
────────────────────────────────────────────────────────────────────────────────
✓ Submission results match expected
✓ Additional module file exports a single function
✓ Additional module file exports a function that takes 3 arguments
✓ Additional module file handles errors properly
✓ Additional module file handles callback argument
✓ Additional module file returned two arguments on the callback function
✗ Your additional module file [mod.js] did not return an Array object as the second argument of the callback
✓ Additional module file returned two arguments on the callback function
✗ Your additional module file [mod.js] did not return an Array object as the second argument of the callback
/usr/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:152
processors[i].call(self, mode, function (err, pass) {
^
TypeError: Cannot read property 'call' of undefined
at next (/usr/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:152:18)
at /usr/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:159:7
at callback (/usr/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:25:15)
at modFileError (/usr/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:30:5)
at /usr/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:120:18
at /home/cocoa/mod.js:11:17
at Array.map (native)
at /home/cocoa/mod.js:10:16
at FSReqWrap.oncomplete (fs.js:112:15)
While I agree that the error text is not helpful, the verification messages stating "Your additional module file [mod.js] did not return an Array object as the second argument of the callback" are attempting to point the student in the right direction. Can I ask if either of you saw that message? If not, I'd be worried that this verification is not catching the case it was intended for.
As far as errors from the exercise verification and bugs go, I can only point you to learnyounode's issue tracker<https://github.com/workshopper/learnyounode/issues>, which already has at least one issue<workshopper/learnyounode#500> relating to this scenario. I agree it would be wonderful for the exercises to be robust and error free, but like most open source projects learnyounode is maintained entirely by volunteers and is always in need of more help. If you find you have the time and the energy to contribute and improve the learning experience for others, then I'm sure your efforts would be appreciated.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#2068 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AZj9k2BQug6HDPyypOvFE54IdpIH3_55ks5rvrmFgaJpZM4M6AP2>.
|
You should execute the callback function only once in the "mymodule" file
|
Working on the modular part of the learnyounode workshop, i get the following error however all the validation steps pass. So i am not sure if the error is in my code or if the validator is failing for some other reason? Appreciate any feedback on what the issue is in this instance.
If you have a problem with an error message:
Error output
This is my filtered-ls.js
and this is my directory-utils.js
The text was updated successfully, but these errors were encountered: