Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19157] Windows: Ti.Filesystem.File.read() fails on device only if file has .js extension

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-07-06T17:40:45.000+0000
Affected Version/sRelease 4.1.0
Fix Version/sRelease 4.1.0
ComponentsWindows
Labelsn/a
ReporterFokke Zandbergen
AssigneeChristopher Williams
Created2015-07-03T13:20:05.000+0000
Updated2015-07-06T20:24:13.000+0000

Description

The following example works in the emulator but fails on the .js file on device:
var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
	title: 'Click'
});

btn.addEventListener('click', function (e) {

	try {
		var txt = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'file.txt');
		txt.write('Hello world');
		txt.read();
	} catch (e) {
		alert('TXT failed: ' + JSON.stringify(e));
	}

	try {
		var js = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'file.js');
		js.write('Hello world');
		js.read();
	} catch (e) {
		alert('JS failed: ' + JSON.stringify(e));
	}

	alert('all OK');
});

win.add(btn);
win.open();

Error

{
  "message": "Could not load module: module_path = C:\\Data\\Users\\DefApps\\APPDATA\\Local\\Packages\com.appc.test_339c21w222ff8\\LocalState\\file.js",
  "native_stack": ["JSExportClass<class Titanium::Filesystem::FIle>::CallNamedFunction"],
  "stack": "read@[native code]\n",
  "line": 1
}
It looks like the .js extension triggers it (but only on device) to use [readRequiredModule](https://github.com/appcelerator/titanium_mobile_windows/blob/master/Source/Global/src/GlobalObject.cpp#L172-L179) and then fails. It's the only place where I could find this error. In addition the attached screenshots also show another bug, where a caught exception in an event listener still causes another exception raised?

Attachments

FileDateSize
IMG_6424.JPG2015-07-03T13:15:10.000+00002356639
IMG_6425.JPG2015-07-03T13:15:32.000+00004132006

Comments

  1. Christopher Williams 2015-07-06

    May be related to TIMOB-19152
  2. Gary Mathews 2015-07-06

    Yes, this was fixed with TIMOB-19152
  3. Lokesh Choudhary 2015-07-06

    Verified the fix. Ti.Filesystem.File.read() does not fail. Closing. Environment: Appc Studio: 4.1.0.201507031129 Ti SDK: 4.1.0.v20150706111546 Ti CLI: 4.0.1 Alloy: 1.6.2 Windows: 8.1 Enterprise 64-bit APPC NPM: 4.1.0-1 APPC CLI: 4.1.0-5 Device: Nokia Lumia 928 - Windows Phone 8.1

JSON Source