Skip to content

Commit

Permalink
Dexie export import fixes (dexie#779)
Browse files Browse the repository at this point in the history
* Typescript compilation error resolved by exporting TypeMapper

* Sporadically, the unit tests of dexie-export-import fails with FileError
This happens mostly on Safari but has also happened on other browser.
Changed the local version of promisedTest() to include the error code from FileError when it happens. Also showing the stack when there's a failure.

The result: FileError with error code 1 happens occationally on Safari when reading a Blob asynchronically (the Blob that resides in IndexedDB).

Due to this erratic behaviour of Blob reading from IndexedDB in Safari, we have to retry the unit tests of dexie-export-import when it fails (retry logic implemented in addons/dexie-export-import/test/travis.sh)
  • Loading branch information
dfahlander authored Nov 27, 2018
1 parent 98fe3d4 commit 1697adc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/dexie-export-import/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ declare var FileReaderSync: {
};
// -----------------------------------------------

interface TypeMapper {
export interface TypeMapper {
binary: ArrayBuffer;
text: string;
}
Expand Down
6 changes: 5 additions & 1 deletion addons/dexie-export-import/test/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export function promisedTest(name: string, tester: ()=>Promise<any>) {
try {
await tester();
} catch (error) {
ok(false, "Got error: " + error);
ok(false, "Got error: " + (error ?
error +
(error.code ? ` (code: ${error.code})` : ``) +
(error.stack ? "\n" + error.stack : '') :
error));
} finally {
start();
}
Expand Down
10 changes: 9 additions & 1 deletion addons/dexie-export-import/test/travis.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
echo "Installing dependencies for dexie-export-import"
npm install >/dev/null
npm run build
npm run test
# This test fails sporadically on Safari 12. Needs to retry it if it fails.
n=1
until [ $n -ge 4 ]
do
echo "Retry $n of 3"
npm run test && exit 0
n=$[$n+1]
done
exit 1

0 comments on commit 1697adc

Please sign in to comment.