How to fix 'write callback called multiple times' - gulp

I am suddenly getting a gulp error that I don't understand for a project that was previously running fine. I haven't changed anything in my gulpfile.js, so I don't understand what caused the error. Can anyone enlighten me?
This is the error I am getting:
Error: write callback called multiple times
at DestroyableTransform.afterTransform (/Users/hannah/Documents/random projects/salamander/node_modules/readable-stream/lib/_stream_transform.js:84:31)
at EventEmitter.signals.on.err (/Users/hannah/Documents/random projects/salamander/node_modules/gulp-cache/lib/index.js:451:7)
at EventEmitter.emit (events.js:198:13)
at DestroyableTransform.onError (/Users/hannah/Documents/random projects/salamander/node_modules/gulp-cache/lib/index.js:288:15)
at Object.onceWrapper (events.js:286:20)
at DestroyableTransform.emit (events.js:203:15)
at Immediate.<anonymous> (/Users/hannah/Documents/random projects/salamander/node_modules/through2-concurrent/through2-concurrent.js:37:14)
at runCallback (timers.js:706:11)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
Emitted 'error' event at:
at DestroyableTransform.onerror (/Users/hannah/Documents/random projects/salamander/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:558:12)
at DestroyableTransform.emit (events.js:198:13)
at DestroyableTransform.afterTransform (/Users/hannah/Documents/random projects/salamander/node_modules/readable-stream/lib/_stream_transform.js:84:17)
at EventEmitter.signals.on.err (/Users/hannah/Documents/random projects/salamander/node_modules/gulp-cache/lib/index.js:451:7)
[... lines matching original stack trace ...]
at runCallback (timers.js:706:11)

In case anyone else has this issue:
I found out that the error was coming from my image minifying task (gulp-imagemin). I had some SVG files in my image folder that I think were structured incorrectly or something. I removed them from the image folder and then gulp started running again.

This is actually due to we are using the imagemin's plugins along with cache.
Please run this npm rebuild jpegtran-bin this will reset it, and run your gulp task comment again!.
thanks.

In my case, it was optimization with imagemin.gifsicle() and a big animated gif-file (57Mb). Resaving the image with PhotoShop didn't help. I'm not sure about the root of the problem, but removing the file solves the problem.

My issue was a dumb one... I am using through2 to pipe and replace the contents of my file and wrapped it as a function. Well, this function was trying to console.log a variable that never gets defined in the branch of logic it was called from.
So yeah, the error message made me look deeper than I needed to since I would have expected an undefined type error instead of the 'write callback called multiple times' I got.

Related

Uncaught (in promise) -- How to find the source of the problem in a Deno program

I'm having trouble with my Deno program. I'm getting messages like this:
error: Uncaught (in promise) Error: No such host is known. (os error 11001)
at deno:core/01_core.js:106:46
at unwrapOpResult (deno:core/01_core.js:126:13)
at async Object.connect (deno:extensions/net/01_net.js:219:13)
Then deno exits.
I don't know how to debug this. This stack trace only points to code that comes with Deno, not to my code.
I've searched my code and I've put a .catch() or a try/catch everywhere I can think of, but that did not help.
Is there anything I can do to help me find the problem? I'd love it if I could get a complete stack dump. Or if I could have the debugger pause at the problem. Or if you have any other suggestions.
Thanks!
Edit 8/29/2021
I found two bugs in my code. Here are the actual bugs. It was a serious pain to track these down. I'm still looking for a tool or process to help the next time I make a silly mistake like this.
Bug #1:
I was using try/catch (shown in red) when I should have been using .catch() (shown in green). My try/catch did nothing. If there was an error sending the data, that would cause my program to crash.
Bug #2:
const promise = Deno.connect(options);
promise.catch(reportError);
promise.then(longRunningTask);
await someOtherPromise;
promise.then(connection => {
// We never get to here.
try {
connection.close();
} catch {
console.log("🙁");
}
});
// And we never get to here.
The code I've shown here was spread throughout a much longer program. I did not understand the rules regarding promises. The second .then() requires a second .catch().
Here was one of my attempts to solve this problem. I told VS code to break on all exceptions. It seems to ignore my request. I never got to a breakpoint, but the debug console shows that the program crashed because of an exception.

feathers-blob error dauria can no read property startsWith

I just started using feathers-blob for uploading files from a angular4 client using dropzone.
I followed the example but made an explicit service for the upload not tu blur up the app.js.
It compiles without error, but on execution i receive the following error, even i do NOT use multipart portion:
Info: error:
system/file-upload - Method: create: Cannot read property 'startsWith'
of undefined error: TypeError: Cannot read property 'startsWith' of
undefined
at Dauria.parseDataURI (/projects/esaas-2/esaas-server-basic/node_modules/feathers-blob/node_modules/dauria/dauria.js:27:17)
at Object.create (/projects/esaas-2/esaas-server-basic/node_modules/feathers-blob/lib/index.js:87:52)
at /projects/esaas-2/esaas-server-basic/node_modules/feathers-hooks/lib/hooks.js:101:31
at /projects/esaas-2/esaas-server-basic/node_modules/feathers-hooks/lib/hooks.js:85:16
I also made sure to use the same versions of feathers-blob and dauria and multer as in the sample and not the newer ones from the npm. Result is the same.
What am i doing wrong? Any help appreciated. Thanks
If you look into dauria's code you'll see where the problem comes from:
Dauria.prototype.parseDataURI = function(dataURI){
if(!( dataURI.startsWith('data:') )) throw new Error(
this.errors.MISSING_PREFIX
);
Which means that somehow the value that you pass to the caller dauria.parseDataURI(yourDataVariable) - the yourDataVariable value does not start with 'data:'.
I made a test on Node and I had the same error while trying to upload an image. I solved it by adding the string "data:image/jpeg;base64" followed by the 64 encoded image.

Polymer website tutorial not running | undefined is not a function

I'm new to polymer and I started to follow this easy first tutorial on the official website
http://www.polymer-project.org/docs/start/tutorial/step-1.html
all was very easy but nothing was working. Or better, I have only one problem. When I tap on the top menu ("All or favourite") nothing changes and I get this error on console
Uncaught TypeError: undefined is not a function Element.js:104
Selected: favorites (index):65
Uncaught TypeError: undefined is not a function Element.js:104
Exception caught during observer callback: TypeError: undefined is not a function
at b.classList (http://127.0.0.1/polymer/components/platform/platform.js:13:20941)
at Polymer.selectedIndexChanged (data:text/javascript;base64,CgogIFBvbHltZXIoJ3BhcGVyLXRhYnMnLCB7CiAgICAKICA…cG9uZW50cy9wYXBlci10YWJzL3BhcGVyLXRhYnMuaHRtbC9wYXBlci10YWJzLmpzCg==:45:26)
at e.invokeMethod (http://127.0.0.1/polymer/components/polymer/polymer.js:12:10242)
at e.notifyPropertyChanges (http://127.0.0.1/polymer/components/polymer/polymer.js:12:9459)
at Object.Observer.report_ (http://127.0.0.1/polymer/components/platform/platform.js:12:12892)
at Object.createObject.check_ (http://127.0.0.1/polymer/components/platform/platform.js:12:18346)
at Object.global.Platform.performMicrotaskCheckpoint (http://127.0.0.1/polymer/components/platform/platform.js:12:13792)
at http://127.0.0.1/polymer/components/platform/platform.js:16:24471
at Object.c [as callback_] (http://127.0.0.1/polymer/components/platform/platform.js:15:9571)
at Array.c (http://127.0.0.1/polymer/components/platform/platform.js:12:27047)
I thought I did something wrong so I downloaded the example file but I have downloaded the source of the example and I still get the same errors.
Any help? =)
Thx everyone!
Some components in the tutorial repo were out of sync. If you pull the updated repo, these errors should go away.
Updating chrome to version 35 or use Chrome Beta
It errors on my linux box which has Chrome Version 34.0.1847.137.
It works on windows7 with Chrome 35.0.1916.153m
I had the same problem.This is the error report https://github.com/Polymer/polymer-tutorial/issues/3
And this is where you can find the answer
https://github.com/Polymer/polymer-tutorial
It worked for me :)

AS3 Error 1180 Call to a possibly undefined method in IntelliJ

I am getting compiler error:
Error 1180: Call to a possibly undefined method when all imports are ok and all method definitions are ok in IntelliJ, double checked?
What could it be?
I had the same trouble, but solution was very easy. One of my package in project was with name "notification" and it had conflict with standart package name, so i had changed name to "notificationS" and compilier had began work without erros.
The thing is if you did some refactoring on the class that you are getting the error, you have to go to menu:
Build > Rebuild Project
If you just do debug or run, it doesnt work for some reason.
I am not sure if the reason is simple refactoring or some git merge, but solution is here.

How to debug a runtime stack underflow error?

I'm really struggling to resolve a stack underflow that I'm getting. The traceback I get at runtime is:
VerifyError: Error #1024: Stack underflow occurred.
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
This is particularly difficult to debug because when I run in debug mode it does not happen at all. It only happens when compiled as a release.
Does anyone have any tips on how to debug a Stack Underflow? Are have a clean explanation of what that means for Flash?
In case it helps, this error is occurring when I click a button whose handler makes an RPC call, which uses a URLLoader, an AsyncToken, and then invokes the set of AsyncResponder instances associated with the AsyncToken. With some server-side logging as well as some logging hacked into the swf, I know that the UrlLoader is successfully doing and GET'ing a crossdomain.xml file, is correctly processing it (ie: if I wreck it, I get a security error), and is also successfully completing the "load" request (the server sends the data). The underflow seems to be happening in the Event.COMPLETE listening/handling process (as is, of course, implied by the traceback as well).
mxmlc used = from flex_sdk_4.5.0.20967
Example player (I've tried a few) = 10.2.153.1
UPDATE: My specific problem is solved... but I'm leaving the question as-is since I would like to know how to generally debug such a problem, rather than just getting my specific solution.
In my code I had the following Application definition:
<s:Application height="100%" width="100%"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="InitData();">
Note that the code is/was attached to the initialize event.
InitData() and relevant defintions are/were:
import classes.RpcServerProxy;
public var SP:RpcServerProxy;
public function InitData():void {
SP = new RpcServerProxy("http://192.168.1.102:1234");
}
When I switched the InitData() call to be on the onCompletion event instead of initialize (thanks J_A_X!), the problem goes away entirely. What seems to have been happening was that the Event.COMPLETE event handler (onComplete in the stack trace) was using the global SP object. Something about the release (vs debug) compilation must have been affecting the startup timing of the SP variable initialization. Moving the handler later to the onCompletion event resolved all issues.
As said above, I would still like to know what tricks/tools are available for debugging initialization issues like this.
UPDATE 2:
applicationComplete seems to be an even better event than creationComplete to put application initialization code. See this blog entry for some explanation, and and this video (around 4:25) by an Adobe Tech Evangelist for an example of simple "start of application" data initialization.
I got rid of this error by adding compiler argument:
-omit-trace-statements=false
Stack underflow basically means the compiler messed up.
You can use SWFWire Inspector to look at the bytecode of the event handler, if you want to know exactly how it messed up. You can also use SWFWire Debugger to see which methods were called, but in this case, you already knew where it was happening.
If you post the broken swf, I can give you more info.
Sean is right that to debug it you can look at the byte code, but that didn't sound appealing to me.
Based on my experience and research, it is often due to the presence of a trace statement that incorrectly gets compiled out in release mode, and generates invalid byte code. So, I would say to "debug" it, "Look for places where you are using trace. Try commenting them all out in the offending function and see if the issue goes away."
In my case, it was a trace statement as the first line of a catch block:
catch (e:TypeError) {
trace(e.getStackTrace()); //This line is the problem
throw new Error("Unexpected type encountered");
}
I found someone else with this exact issue here.
This code also leads to stack underflow only in release mode (flag -debug=false):
true && trace('123');
mxlmc flex sdk version 4.5.0.20967, flashplayer version 10.3.181.14 (linux).
Check your code for similar expressions.
This code caused me issues when I compiled a release candidate from flash builder 4.5
public function set configVO( value:PopupConfigVO ):void
{trace("CHANGING")
Resolved by inserting a space between the the trace and curly brace
public function set configVO( value:PopupConfigVO ):void
{ trace("CHANGING")
Hope this helps.
For people looking for the same problem, I just got this caused by a trace statement in the 'default' case of a switch statement. Commented out the trace, stack underflow resolved.
Interesting... I was getting this error with a SWF that I'd pulled off the web, an Away3D based graphics demo. At the time I was running this on the Tamarin VM rather than the actual Flash/AIR runtimes, so could stick a breakpoint on the "verifyFailed(kStackUnderflowError)" line and see what was happening.
The -Dverbose flag also helped find the culprit:
typecheck MethodInfo-1480()
outer-scope = [global]
[Object~ Object] {} ()
0:pop
VERIFY FAILED: Error #1024: Stack underflow occurred.
And looking at the ABC using SWFInvestigator, I found this:
var function(Object):void /* disp_id=0 method_id=1480 nameIndex = 0 */
{
// local_count=2 max_scope=0 max_stack=0 code_len=2
// method position=52968 code position=155063
0 pop
1 returnvoid
}
So there is an obvious issue where the 'trace' has been removed but the compiler has put a 'pop' in there: I wouldn't have thought this was needed as a trace call should presumably have been made via 'callpropvoid'?
Quite why this doesn't fail on AIR/Flash I don't know..
Anyway: looks to me like an ASC compiler problem i.e perhaps one of the ActionScript3 compilers had a fault with this - hence the workarounds that have been mentioned so far.
It's quite simple, and it doesn't have anything to do with spaces before or after brackets, trace commands or whatever else: it's just 1 really simple thingy:
DO NOT LOOP EMPTY!
Meaning, while developing, we all //comment some lines sometimes, and when that results in
for (...) {
// skip for now
}
the compiler gets :
for(...){}
and that my good friends, is something the compiler doesn't like!
so, NO empty loops, and you're on your way again...
Happy hunting,
P.
I had the exact same problem, but in my case the cause of the problem was a trace statement in a place where the compiler didn't expect it to find it, right after a package declaration at the beginning of the class:
package utils
{
trace ("trace something here");
And that's why compiling in debug mode removed the problem.