Commit graph

11 commits

Author SHA1 Message Date
Dan Stillman
cd2898ece3 Update Bluebird to v2.9.27 2015-06-08 04:05:46 -04:00
Dan Stillman
6b87c641d9 Experimental approach to cancelling unnecessary promises
If a view or other resources are destroyed while a promise is being
resolved, subsequent code can fail. This is generally harmless, but it
results in unnecessary errors being logged to the console.

To address this, promises can use a new function,
Zotero.Promise.check(), to test whether a value is truthy or 0 and
automatically throw a specific error that's ignored by the unhandled
rejection handler if not.

Example usage:

getAsync().tap(() => Zotero.Promise.check(this.win));

If this.win is cleaned up while getAsync() is being resolved, subsequent
lines won't be run, and nothing will be logged to the console.
2015-05-23 04:43:37 -04:00
Dan Stillman
aa70e60fc6 Add clearTimeout() implementation to Bluebird
Necessary for cancellable promises
2015-05-10 18:30:06 -04:00
Dan Stillman
90f4996d9d Remove some excessive error logging from Bluebird
And hide errors from DB transaction rollback tests
2015-04-25 03:17:41 -04:00
Dan Stillman
0b21c4c682 Still show proper line number when no message is thrown 2015-02-05 19:01:55 -05:00
Dan Stillman
c322eaa1bc Restore Error workaround in Bluebird to produce proper line numbers
I didn't really investigate this, but errors from the outside world seem
to not pass the "obj instanceof Error" test due to some weirdness that
Bluebird is doing. (When I took this out recently I thought we just were
throwing some custom errors that didn't properly extend Error, but that
isn't the issue.) This restores the earlier workaround.
2015-02-05 18:39:43 -05:00
Dan Stillman
91d14fc04c Use 'self' instead of 'global' as global object in Bluebird
This fixes an error when other errors occur in recent versions of Bluebird.
2015-02-03 15:36:01 -05:00
Dan Stillman
d660a84f47 Update Bluebird to 2.9.6 2015-02-03 15:36:01 -05:00
Dan Stillman
30b5c4686e Update Bluebird to 2.9.3
...with fewer modifications, since one (better debug info on an invalid
yield value) was implemented in Bluebird and the other (detecting a
thrown error that doesn't properly extend Error) we should just fix in
our code.
2015-01-28 15:19:29 -05:00
Dan Stillman
7541106641 Update Bluebird to 2.3.5
Our modifications no longer include a custom yield handler to
automatically call all() on yielded arrays (which maintained Bluebird
1.x behavior). It's now necessary to call all() or similar explicitly.

Also fixed a few incorrect yields hidden by that behavior.
2014-10-09 14:21:10 -04:00
Dan Stillman
db0fa3c33e Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.

WARNING: This includes backwards-incompatible schema changes.

An incomplete list of other changes:

- Schema overhaul
  - Replace main tables with new versions with updated schema
  - Enable real foreign key support and remove previous triggers
  - Don't use NULLs for local libraryID, which broke the UNIQUE index
    preventing object key duplication. All code (Zotero and third-party)
    using NULL for the local library will need to be updated to use 0
    instead (already done for Zotero code)
  - Add 'compatibility' DB version that can be incremented manually to break DB
    compatibility with previous versions. 'userdata' upgrades will no longer
    automatically break compatibility.
  - Demote creators and tags from first-class objects to item properties
- New API syncing properties
  - 'synced'/'version' properties to data objects
  - 'etag' to groups
  - 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway

Known broken things:

- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)

Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 22:59:37 -04:00