Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "js-data requires a global Promise constructor!" in IE #265

Closed
mobidev111 opened this issue Nov 10, 2015 · 2 comments
Closed

Error "js-data requires a global Promise constructor!" in IE #265

mobidev111 opened this issue Nov 10, 2015 · 2 comments

Comments

@mobidev111
Copy link

Situation: js-data with localForage adapter

setup

  • js-data
  • js-data-angular
  • localForage adapter - because of the angular promises implementation I use dist/localforage.nopromises.js

environment

  • browser at runtime: Internet Explorer (IE)
  • js-data files and vendor libraries packaged with browserify
  • js-data used in browser only

Problem: js-data fails in IE with "js-data requires a global Promise constructor!"

when using dist/localforage.nopromises.js - v1.3.0:

JavaScript runtime error: 'Promise' is undefined

at

// There might be a driver initialization in progress
// so wait for it to finish in order to avoid a possible
// race condition to set _dbInfo
var oldDriverSetDone = this._driverSet !== null ? this._driverSet['catch'](function () {
  return Promise.resolve();
}) : Promise.resolve();

followed by:

"js-data requires a global Promise constructor!"

even when using dist/localforage.js - v1.3.0:

"js-data requires a global Promise constructor!"

odd: only fails in IE

The exact same setup works on Chrome and Safari.

@jmdobry
Copy link
Member

jmdobry commented Nov 10, 2015

"js-data requires a global Promise constructor!"

This is only an annoying warning (which I will remove in the future). This warning will be printed to the console if js-data can't find window.Promise, but it won't cause js-data to fail. If you're loading js-data-angular like this:

angular.module('myApp', [require('js-data-angular')]).config(...)

Then you don't even need to do require('js-data')

localforage.nopromises.js requires there to be window.Promise, which is why is failing in IE. localforage.nopromises.js is not going to figure out that it can use the $q service provided by Angular. I would recommend adding a polyfill to your environment.

@jmdobry
Copy link
Member

jmdobry commented Jan 6, 2016

Warning is no longer printed in v3. But, js-data is still dependent on window.Promise (or global.Promise).

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

No branches or pull requests

2 participants