PDA

View Full Version : [NOREPRO] Synchronous loading fails if async loading of same class is on going



mbizon
10 Oct 2011, 2:32 PM
Ext version tested:

Ext 4.02 rev a


Browser versions tested against:

FF7
Chrome 14.0.835.202


Description:

The attached test case fails with this error "Cannot create an instance of unrecognized class name / alias: Ext.data.proxy.Rest" despite warning earlier that the class will be synchronously loaded.

The error goes away if I manually require the class name using Ext.require() or "require" field in application.

While debugging this I see two async require() calls for "Ext.data.Model" then "proxy.rest", immediately followed by a syncRequire() call for "Ext.data.proxy.Rest".

The latter is "ignored" because it's already on-going, and we get out of syncRequire() without actually loading the class.



Test Case:



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test App</title>

<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
<script type="text/javascript" src="extjs/ext-dev.js"></script>
<script type="text/javascript" src="app.js"></script>

</head>
<body></body>
</html>




Ext.Loader.setConfig({
enabled : true,
paths : {
'Ext': 'extjs/src',
}
});

Ext.application({
name: 'MyApp',

launch: function() {

Ext.create('Ext.data.Store', {

fields : [ 'foo', 'bar' ],

proxy: {
type: 'rest',
url : '/users',
reader: {
type: 'json',
root: 'items'
}
}
});
}
});





Possible fix:

The following patch is a crude fix, it may causes missing scripts to be loaded twice. It fixes my problem but I don't really like it.



--- Loader.js.old 2011-10-10 23:54:57.344377856 +0200
+++ Loader.js 2011-10-10 23:55:54.545384858 +0200
@@ -722,7 +722,8 @@ If you are unsure which license is appro
for (i = 0, ln = classNames.length; i < ln; i++) {
className = classNames[i];

- if (!this.isFileLoaded.hasOwnProperty(className)) {
+ if (!this.isFileLoaded.hasOwnProperty(className) ||
+ (this.syncModeEnabled && this.isFileLoaded[className] == false)) {
this.isFileLoaded[className] = false;

filePath = this.getPath(className);

SebTardif
6 Aug 2012, 10:35 AM
That seems an important bug. We have a similar issue where model referenced by stores are not fully loaded, so not registered before store crashes on not finding the model in the registry.

evant
6 Aug 2012, 7:43 PM
This is an old one and I can't reproduce it with the test case provided and the current code.