Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Error: Module build failed: Error: Final loader didn't return a Buffer or String #466

Closed
fiznool opened this issue Nov 23, 2016 · 43 comments
Assignees

Comments

@fiznool
Copy link
Contributor

fiznool commented Nov 23, 2016

Short description of the problem:

When using ionic serve, sometimes I get the error:

Error: Module build failed: Error: Final loader didn't return a Buffer or String

I have to restart ionic serve to make the error go away.

Which @ionic/app-scripts version are you using?

0.0.46

Other information:

Here's a screenshot of the issue:

screenshot from 2016-11-23 15-42-26

@MarkChrisLevy
Copy link

I confirm that issue as well.

@fiznool
Copy link
Contributor Author

fiznool commented Nov 24, 2016

I've downgraded to 0.0.44 - seems to have fixed the issue for now.

@danbucholtz
Copy link
Contributor

Any idea how to recreate the issue?

Thanks,
Dan

@fiznool
Copy link
Contributor Author

fiznool commented Nov 30, 2016

@danbucholtz sorry, I don't know. All I know, is it happens sporadically on 0.0.45 and 0.0.46. I haven't seen this issue crop up since I downgraded to 0.0.44.

I'm afraid that I can't share the source code with you as it is private.

@MarkChrisLevy
Copy link

MarkChrisLevy commented Nov 30, 2016

@danbucholtz It seems, that it happens when I change the ts file (that starts transpile etc) and just right after I change the same ts file again:

[16:00:21]  build started ... 
[16:00:21]  transpile update started ... 
[16:00:21]  transpile update finished in 152 ms 
[16:00:21]  webpack update started ... 
[16:00:29]  build started ... 
[16:00:32]  transpile update started ... 
[16:00:32]  transpile update finished in 107 ms 
[16:00:32]  webpack update started ... 
[16:00:36]  webpack update finished in 4.55 s 
[16:00:36]  build finished in 15.83 s 

[16:00:36]  build finished in 7.90 s 

Look, that build started two times, transpile started two times, webpack started two times as well, but finished only once.

But it doesn't happen all the time, probably the second change must be made in appropriate time and generates race condition...

@danbucholtz
Copy link
Contributor

Hmmm, okay, I will try to break it and fix it. Thanks @lleevvyy!

Thanks,
Dan

@danbucholtz danbucholtz self-assigned this Dec 4, 2016
@fiznool
Copy link
Contributor Author

fiznool commented Dec 7, 2016

An update to this.

I put some debug logging inside the module which throws the error, node_modules/webpack/lib/NormalModule.js:150:

if(!Buffer.isBuffer(source) && typeof source !== "string") {
	console.log(result);
	return callback(module.error = new ModuleBuildError(module, new Error("Final loader didn't return a Buffer or String")));
}

It's happened to me a couple of times again today. Here is the result of the console logging:

{ result: 
   [ null,
     { version: 3,
       file: 'app.operators.js',
       sourceRoot: '',
       sources: [Object],
       names: [],
       mappings: 'AAAA,kEAAkE;OAG3D,+BAA+B;OAC/B,iCAAiC;OACjC,wBAAwB;OACxB,yBAAyB;OAGzB,yBAAyB;OACzB,gCAAgC;OAChC,wCAAwC;OACxC,uBAAuB;OACvB,4BAA4B;OAC5B,6BAA6B;OAC7B,6BAA6B;OAC7B,6BAA6B',
       sourcesContent: [Object] } ],
  resourceBuffer: <Buffer 2f 2f 20 49 6d 70 6f 72 74 20 6a 75 73 74 20 74 68 65 20 72 78 6a 73 20 73 74 61 74 69 63 73 20 61 6e 64 20 6f 70 65 72 61 74 6f 72 73 20 6e 65 65 64 ... >,
  cacheable: true,
  fileDependencies: [ '/app/src/app/app.operators.ts' ],
  contextDependencies: [] }

This is the contents of app.operators.ts:

// Import just the rxjs statics and operators needed for THIS app.

// Statics
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/zip';

// Operators
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/startWith';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/takeWhile';

I import this in my app.component.ts like so:

// Add the RxJS Observable operators.
import './app.operators';

Maybe this is of some help?

@thruthesky
Copy link

thruthesky commented Dec 10, 2016

Good morning,

I was thinking it happens, on my end, because I use 'ng-bootstrap modal' and add it 'entryComponent' but now I experience even without 'ng-bootstrap modal'.

Thank you.

@cmaart
Copy link
Contributor

cmaart commented Dec 12, 2016

Can confirm. It's horrible because it constantly breaks development.

@ionic/app-scripts 0.0.46
ionic-angular 2.0.0-rc.3
Windows 10

@danbucholtz
Copy link
Contributor

Anyone know how to recreate? I cannot recreate it. I will fix if someone can give steps to reproduce it.

Thanks,
Dan

@gust42
Copy link
Contributor

gust42 commented Dec 14, 2016

I can reproduce this!

I start my app using ionic serve -b

  1. save a .html template in VS Code, wait for the browser reload
  2. save a .ts component in VS Code, the error message appears after reload

the error persist if i save a .ts but if i save a .html again, the error disappears,

Ionic Framework: ^2.0.0-rc.3
Ionic Native: 2.2.3
Ionic App Scripts: 0.0.47
Angular Core: 2.1.1
Angular Compiler CLI: 2.1.1
Node: 6.9.1
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36

image

@danbucholtz
Copy link
Contributor

I'll check it out, thanks @gust42!

Thanks,
Dan

@danbucholtz
Copy link
Contributor

danbucholtz commented Dec 15, 2016

@gust42,

Sorry, those steps don't work for me. I just tried them out. I have never once seen this issue in developing on Mac or Windows 10.

Are you using barrel files? Could that be why? Barrel files are not considered a best practice and cause all sorts of problems. I think Angular will stop recommending them soon based on some conversations we've had with the team.

Do you get the issue if you set ionic_bundler to rollup?

Thanks,
Dan

@gust42
Copy link
Contributor

gust42 commented Dec 15, 2016

Yes we are using barrels, they make imports so much more elegant but i guess we have to refactor them away.

Latest nightly with new webpack seems to remove Final Loader issue, but now it hangs when saving a .html 2 times in a row, without any .ts changes, for some reason it does a full transpile the second time saving the template. Saving a .ts start a new full transpile where webpack update succeeds

image

Edit: Made a pull request for the new error #557

@tkem
Copy link

tkem commented Dec 15, 2016

I suddenly ran into the same issue, to the point where ionic serve became almost unusable.
Since I haven't had this issue with ionic-app-scripts 0.0.46 before, I started looking for other changes to my build environment.
For me, downgrading the Ionic CLI to version 2.1.12 seems to solve this (haven't had this issue for the last 20 edits or so, while it occurred on average with every third save before).
So this may actually be related to ionic-cli and not to ionic-app-scripts.
Note that I'm using neither Mac nor Windows, but had this same issue both on Ubuntu 16.04 and Debian Wheezy.

Cordova CLI: 6.3.1 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.2
Node Version: v5.12.0
Xcode version: Not installed

@fiznool
Copy link
Contributor Author

fiznool commented Dec 15, 2016

FWIW I've yet to see this error occur since upgrading to app scripts 0.0.47.

Literally 5 mins after I wrote this, the error happened again.

@fiznool
Copy link
Contributor Author

fiznool commented Dec 15, 2016

I've also noticed that there might be some correlation with this happening when saving the HTML template files. Just now, when saving both the ts and corresponding HTML template file at the same time (using my editor's 'Save All' command), I see the error.

I've also noticed an error whereby if I save a HTML file, wait for the app to reload, then make a change to the corresponding ts file, save again, the old version of the HTML file reloads in the browser. I recall a separate issue regarding this but I can't currently find it, but I wonder if this is also part of the issue.

@danbucholtz
Copy link
Contributor

I'll do some more testing around this tonight.

Thanks,
Dan

@tkem
Copy link

tkem commented Dec 15, 2016

Highly appreciated, thanks @danbucholtz!

@danbucholtz
Copy link
Contributor

@fiznool, what are the details on your system. What node version, OS, etc.

I am going to add some additional logging, etc to the loader so we can hopefully track this down.

I doubt the CLI has anything to do with this. All of the watching, etc happens in app-scripts.

If anyone can recreate a repo and provide steps to do it, I can and will most certainly fix it or raise the flag that we need a major change to fix it.

Thanks,
Dan

@fiznool
Copy link
Contributor Author

fiznool commented Dec 15, 2016

Thanks, my OS is Ubuntu 16.10, node version 6.7.9.

@tkem
Copy link

tkem commented Dec 15, 2016

@danbucholtz: Sure:
https://github.com/tkem/openlap

tkem@xps15:~/src/openlap$ ionic info

Your system information:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v6.9.1
Xcode version: Not installed

screenshot from 2016-12-15 19-18-55
The action that triggered this was inserting a random newline in src/rms/race-settings-page.ts, though it took me six tries to finally see this after initial checkout/ionic serve -acs-
Editor is vscode for Linux, in case it may be relevant (I had some issues with Emacs before, probably due to the way it handles saved files and backup copies):

Version 1.7.2
Commit 7ba55c5860b152d999dda59393ca3ebeb1b5c85f
Date 2016-11-21T22:14:18.217Z
Shell 1.3.8
Renderer 52.0.2743.82
Node 6.5.0

@tkem
Copy link

tkem commented Dec 15, 2016

OS is ubuntu 16.04 LTS, to be more specific.

@tkem
Copy link

tkem commented Dec 15, 2016

Oh, and - as you may have figured out yourself - Browser is Chromium

Version 53.0.2785.143 Built on Ubuntu , running on Ubuntu 16.04 (64-bit

but I've seen the same behavior on Chrome for Windows, connecting remotely (hence the -a to ionic serve).

@bobrosoft
Copy link

bobrosoft commented Dec 16, 2016

Daamn, just started to expirience the same ...

Your system information:

Cordova CLI:  You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.4.0

Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: Not installed
ios-sim version: Not installed
OS: OS X El Capitan
Node Version: v6.5.0
Xcode version: Not installed

What I noticed: if I change .html -- it starts to work again, if I change .ts -- it dropping that issue :(

@bobrosoft
Copy link

Just downgraded ionic-cli to 2.1.15 with npm install -g [email protected] (was 2.1.17) -- looks fine for now.

@danbucholtz
Copy link
Contributor

It seems highly unlikely that it's related to the Ionic CLI. It would be better to use ionic@latest.

Thanks,
Dan

@bobrosoft
Copy link

Dunno, @tkem said the same here #466 (comment) and downgrade helped to me. Also thanks for fixing #533, will try it later.

@danbucholtz
Copy link
Contributor

Please keep trying to recreate with the newest CLI. How often does this happen? Every time you develop with Ionic after a few saves? first save? Randomly once every few days?

I added a bunch of logging and unit tests to the code here that will be released in 0.0.48.

Thanks,
Dan

@bobrosoft
Copy link

bobrosoft commented Dec 16, 2016

@danbucholtz sorry, I need to deploy things to Production today so need stability and can't switch to latest for now.

"How often does this happen? Every time you develop with Ionic after a few saves? first save? Randomly once every few days?" -- can't say for 100%, but it starts right after ionic serve -a when you change .ts file. After that any change in .ts will not fix things, but any change in .html will. Only what I noticed, things starts to work when console writes transpile started but not transpile update started, I think related to watchers and loaders which process changes.

@danbucholtz
Copy link
Contributor

Hi all,

I added a ton of logging in 0.0.48 (which we just released). Can you try to recreate? If you can, can you run the same command with the --debug flag and see if it gives us anything useful?

Thanks,
Dan

@gust42
Copy link
Contributor

gust42 commented Dec 22, 2016

have done a couple of hours of development today without seeing the final loader thingy on 0.0.48

Edit: Before i was seeing it all the time

@danbucholtz
Copy link
Contributor

@gust42,

w00t!

Is anyone else still seeing this issue?

Thanks,
Dan

@fiznool
Copy link
Contributor Author

fiznool commented Dec 23, 2016

Unfortunately I've been unable to test at all with 0.0.48 due to #590

@thruthesky
Copy link

Good afternoon.
So far, I don't see it yet.
Thank you.

@tkem
Copy link

tkem commented Dec 23, 2016

@danbucholtz: Haven't seen this in two hours of intensive editing with v0.0.48 and ionic@latest.
👍
Will enable --debug and post here if it shows up again. Note, though, that I have to use

"config": {
  "ionic_source_map_type": "eval"
}

for v0.0.48 to work at all for me, as detailed in #562.

@abdel-ships-it
Copy link
Contributor

abdel-ships-it commented Dec 30, 2016

Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: 1.9.0 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v6.9.1
Xcode version: Xcode 8.2.1 Build version 8C1002

@danbucholtz I think I found out when this issue occurs. I don't have logging enabled, but could upgrade to enable it as I am on 0.0.47 right now.

Here is how to recreate this issue

Save a HTML file -> while its building save its corresponding TS file

Edit: I see that @gust42 already found this out, sorry!

@danbucholtz
Copy link
Contributor

I'll check it out @realappie. Thanks!

Maybe we need to queue up builds if there is an active build running. Hmmm.

Thanks,
Dan

@fiznool
Copy link
Contributor Author

fiznool commented Jan 4, 2017 via email

@danbucholtz
Copy link
Contributor

Can anyone recreate this issue with 0.0.48?

Thanks,
Dan

@MarkChrisLevy
Copy link

@danbucholtz I cannot recreate it with 0.0.48, so if you would ask me I would close the issue for now.

@tkem
Copy link

tkem commented Jan 5, 2017

@danbucholtz: Haven't seen this in quite some time either, so maybe time to fry the "smaller fish" (#562)...

@danbucholtz
Copy link
Contributor

I'm going to close this for now, but I will reopen if we see a recreation.

Thanks,
Dan

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants