Where are the `window.ethereum` docs? - ethereum

I'm calling window.ethereum and there are all these functions but it's confusing what they accept and the types. My understanding is that MetaMask injects something into window.ethereum... so I assume all the methods are from MetaMask? If so, are all the methods different for Coinbase wallet then?
Where are the docs for window.ethereum?
Are there any types associated with this?
My console when I console.log(window.ethereum);
coinbase - window.ethereum
w {_events: {…}, _eventsCount: 4, _maxListeners: undefined, _filterPolyfill: e.FilterPolyfill, _subscriptionManager: e.SubscriptionManager, …}
close: ƒ ()
enable: ƒ ()
genericRequest: ƒ ()
getChainId: ƒ ()
hasMadeFirstChainChangedEmission: false
isCoinbaseWallet: true
request: ƒ ()
scanQRCode: ƒ ()
send: ƒ ()
sendAsync: ƒ ()
setAppInfo: ƒ ()
setProviderInfo: ƒ ()
updateProviderInfo: ƒ ()
_addresses: ['0xmyAddress']
_eventListener: undefined
_events: {chainChanged: Array(2), accountsChanged: Array(2), connect: ƒ, message: ƒ}
_eventsCount: 4
_filterPolyfill: e.FilterPolyfill {logFilters: Map(0), blockFilters: Set(0), pendingTransactionFilters: Set(0), cursors: Map(0), timeouts: Map(0), …}
_jsonRpcUrlFromOpts: "https://mainnet-infura.wallet.coinbase.com"
_maxListeners: undefined
_overrideIsMetaMask: false
_relay: S {appName: 'localhost:3000', appLogoUrl: 'http://localhost:3000/favicon.ico', subscriptions: t, accountsCallback: ƒ, chainCallback: ƒ, …}
_relayEventManager: e.WalletSDKRelayEventManager {_nextRequestId: 0, callbacks: Map(0)}
_relayProvider: async ƒ I()
_send: ƒ ()
_sendAsync: ƒ ()
_setAddresses: ƒ ()
_storage: e.ScopedLocalStorage {scope: '-walletlink:https://www.walletlink.org'}
_subscriptionManager: e.SubscriptionManager {events: o, subscriptionMiddleware: ƒ}
chainId: (...)
connected: (...)
host: (...)
isChainOverridden: (...)
isMetaMask: (...)
isWalletLink: (...)
jsonRpcUrl: (...)
networkVersion: (...)
selectedAddress: (...)
[[Prototype]]: o
For example:
I can't find setProviderInfo in the Ethereum docs
I can't find setProviderInfo in the Metamask docs either
Just to show I'm not lazy... Coinbase wallet docs are here

window.ethereum is described in EIP-1193.
EIP-1193 specification.

Related

Unload Extension Autodesk.FullScreen from Forge Viewer is not working

Hello and thanks for taking time to read this,
we developing an App with Autodesk Forge for displaying informations related to some specific components. In this context we disabled and unloaded a few Extensions which are preLoaded by the Forge Viewer. Which is similar to this StackOverflow -- Unload Forge Extensions.
We also want to unload the 'Autodesk.FullScreen' und purpose of our Users. https://forge.autodesk.com/en/docs/viewer/v7/reference/Extensions/FullScreenExtension/
Following i added the Code we tried in Console of the Browser with the provided result:
First we let us show the loaded extensions:
NOP_VIEWER.getLoadedExtensions()
{Autodesk.BIM360.Minimap: l, BasicExtension: U, Autodesk.ViewCubeUi: Y, Autodesk.CompGeom: l, Autodesk.LayerManager: P, …}
Autodesk.BIM360.Minimap: l {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.BoxSelection: r {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.CompGeom: l {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.LayerManager: P {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.Measure: Pe {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.Section: _ {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.Snapping: c {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
Autodesk.ViewCubeUi: Y {viewer: C, globalManager: e, setGlobalManager: ƒ, onSetGlobalManager: ƒ, getWindow: ƒ, …}
BasicExtension: U {viewer: C, extOptions: {…}, eventArgsTypeMap: {…}, eventStreams: Array(10), events: Array(10), …}
[[Prototype]]: Object
Here we don't the the Autodesk.FullScreen Extensions which is a bit strange. Because it is definitly in the Toolbar and useable as you can see on the attached Image in the end of this Post...
Optimistic as we are we try to unload it:
NOP_VIEWER.unloadExtension('Autodesk.FullScreen')
false
As expected we getting a false... But nevermind to be sure we check if its loaded:
NOP_VIEWER.getExtension('Autodesk.FullScreen')
null
As expected we getting a null back. But the Extension is still there and working?
So what is the difference here to the other Extensions? Is it as designed? If it so, than the Documentation is missleading here. Maybe someone has a idea? Fun Fact you can see the same behaviour regarding to the 'Autodesk.ViewerSettings' Extension Autodesk Forge - Autodesk.ViewerSettings Extension
Showing Taskbar with Extensions
Is there something different about this Extension? Can it be unloaded or is it in another Context and the complete Toolbar needs to be removed? Maybe to mention that the Button is unloaded on a Mobile Device by default. So there must be some working mechanism to unload it.
Take a look at this post which describes how to remove toolbar buttons and when : When to remove toolbar buttons
You can intercept the TOOLBAR_CREATED_EVENT and remove the related control.

Error retrieving access token FetchError: request to https://oauth2.googleapis.com/token failed, reason: read ECONNRESET

I am tring to log Gdrive in vscode software. And I according the step of url: https://developers.google.com/drive/api/v3/quickstart/nodejs to do it. But when I run step 4 about node .
in terminal, this question occured. Can anyone tell me how to solve it.
PS D:\VScode> node .
Authorize this app by visiting this url: https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&response_type=code&client_id=668097439811-r1jtctrhhnlptug6ghn3snkpckttokgs.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
Enter the code from that page here: 4/1AY0e-g7XilzG82JRv7SNkYA0ou6TdmbIYQqZWpWA1ZzuPq6Fc791-1FxA3o
Error retrieving access token FetchError: request to https://oauth2.googleapis.com/token failed, reason: read ECONNRESET
at ClientRequest. (D:\VScode\node_modules\node-fetch\lib\index.js:1461:11)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
type: 'system',
errno: 'ECONNRESET',
code: 'ECONNRESET',
config: {
method: 'POST',
url: 'https://oauth2.googleapis.com/token',
data: 'code=4%2F1AY0e-g7XilzG82JRv7SNkYA0ou6TdmbIYQqZWpWA1ZzuPq6Fc791-1FxA3o&client_id=668097439811-r1jtctrhhnlptug6ghn3snkpckttokgs.apps.googleusercontent.com&client_secret=vmwOLcfpcTVJQMBBILSfprAB&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code&code_verifier=',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'google-api-nodejs-client/3.1.2',
Accept: 'application/json'
},
params: [Object: null prototype] {},
paramsSerializer: [Function: paramsSerializer],
body: 'code=4%2F1AY0e-g7XilzG82JRv7SNkYA0ou6TdmbIYQqZWpWA1ZzuPq6Fc791-1FxA3o&client_id=668097439811-r1jtctrhhnlptug6ghn3snkpckttokgs.apps.googleusercontent.com&client_secret=vmwOLcfpcTVJQMBBILSfprAB&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code&code_verifier=',
validateStatus: [Function: validateStatus],
responseType: 'json'
}
}
You can try to set up your http/https proxy for node CLI env.
process.env.HTTPS_PROXY = 'Your proxy';
google.options({ proxy: 'Your proxy' });

Is anyone else experiancing a Syncfusion Pivot Grid remote data error?

Typescript Version: 3.2.4
Angular version: ^7.2.15
Syncfusion Version: 17.1.50
Hi all. I am having an issue with Syncfusion's Pivot Grid. The code below is my onInit method which is taken straight from their demo. This was working as of 17.1.41 but now has magically stopped working. This issue is also on their StackBlitz example.
ngOnInit() {
let data: DataManager;
data = new DataManager({
url: this._controllerUrl + "/billing/extract",
adaptor: new WebApiAdaptor(),
crossDomain: true,
headers: [
{
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer " + this.token
}
]
});
this.dataSource = {
enableSorting: true,
columns: [{ name: "Year" }, { name: "Month" }],
values: [{ name: "Cost", caption: "Cost (GBP)" }],
data: data,
rows: [{ name: "ServiceId" }],
formatSettings: [],
expandAll: false,
filters: []
};
this.button = new Button({ isPrimary: true });
this.button.appendTo("#export");
this.button.element.onclick = (): void => {
this.pivotGridObj.excelExport();
};
}
Here is the full error in Firefox:
ERROR Error: "Uncaught (in promise): TypeError: this.parent.dataSource.values is undefined
./node_modules/#syncfusion/ej2-pivotview/src/common/grouping-bar/axis-field-renderer.js/AxisFields.prototype.createPivotButtons#http://localhost:4200/views-billing-billing-module.js:197167:17
./node_modules/#syncfusion/ej2-pivotview/src/common/grouping-bar/axis-field-renderer.js/AxisFields.prototype.render#http://localhost:4200/views-billing-billing-module.js:197143:14
./node_modules/#syncfusion/ej2-pivotview/src/common/grouping-bar/grouping-bar.js/GroupingBar.prototype.appendToElement#http://localhost:4200/views-billing-billing-module.js:197347:49
./node_modules/#syncfusion/ej2-base/src/observer.js/Observer.prototype.notify#http://localhost:4200/views-billing-billing-module.js:10781:25
./node_modules/#syncfusion/ej2-base/src/component.js/Component.prototype.notify#http://localhost:4200/views-billing-billing-module.js:5505:32
./node_modules/#syncfusion/ej2-pivotview/src/pivotview/base/pivotview.js/PivotView.prototype.renderPivotGrid#http://localhost:4200/views-billing-billing-module.js:204990:18
./node_modules/#syncfusion/ej2-base/src/observer.js/Observer.prototype.notify#http://localhost:4200/views-billing-billing-module.js:10781:25
./node_modules/#syncfusion/ej2-base/src/component.js/Component.prototype.notify#http://localhost:4200/views-billing-billing-module.js:5505:32
./node_modules/#syncfusion/ej2-pivotview/src/pivotview/base/pivotview.js/PivotView.prototype.initEngine#http://localhost:4200/views-billing-billing-module.js:206000:14
./node_modules/#syncfusion/ej2-pivotview/src/pivotview/base/pivotview.js/PivotView.prototype.executeQuery#http://localhost:4200/views-billing-billing-module.js:206047:14
./node_modules/zone.js/dist/zone.js/</ZoneDelegate.prototype.invoke#http://localhost:4200/polyfills.js:7688:26
onInvoke#http://localhost:4200/vendor.js:82616:33
./node_modules/zone.js/dist/zone.js/</ZoneDelegate.prototype.invoke#http://localhost:4200/polyfills.js:7687:52
./node_modules/zone.js/dist/zone.js/</Zone.prototype.run#http://localhost:4200/polyfills.js:7447:43
scheduleResolveOrReject/<#http://localhost:4200/polyfills.js:8186:34
./node_modules/zone.js/dist/zone.js/</ZoneDelegate.prototype.invokeTask#http://localhost:4200/polyfills.js:7720:31
onInvokeTask#http://localhost:4200/vendor.js:82607:33
./node_modules/zone.js/dist/zone.js/</ZoneDelegate.prototype.invokeTask#http://localhost:4200/polyfills.js:7719:60
./node_modules/zone.js/dist/zone.js/</Zone.prototype.runTask#http://localhost:4200/polyfills.js:7492:47
drainMicroTaskQueue#http://localhost:4200/polyfills.js:7898:35
./node_modules/zone.js/dist/zone.js/</ZoneTask.invokeTask#http://localhost:4200/polyfills.js:7799:21
invokeTask#http://localhost:4200/polyfills.js:9041:14
globalZoneAwareCallback#http://localhost:4200/polyfills.js:9067:17
Here is the full error in Chrome/Edge
core.js:15724 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at AxisFields.push../node_modules/#syncfusion/ej2-pivotview/src/common/grouping-bar/axis-field-renderer.js.AxisFields.createPivotButtons (axis-field-renderer.js:45)
at AxisFields.push../node_modules/#syncfusion/ej2-pivotview/src/common/grouping-bar/axis-field-renderer.js.AxisFields.render (axis-field-renderer.js:21)
at GroupingBar.push../node_modules/#syncfusion/ej2-pivotview/src/common/grouping-bar/grouping-bar.js.GroupingBar.appendToElement (grouping-bar.js:142)
at Observer.push../node_modules/#syncfusion/ej2-base/src/observer.js.Observer.notify (observer.js:89)
at PivotViewComponent.push../node_modules/#syncfusion/ej2-base/src/component.js.Component.notify (component.js:188)
at PivotViewComponent.push../node_modules/#syncfusion/ej2-pivotview/src/pivotview/base/pivotview.js.PivotView.renderPivotGrid (pivotview.js:881)
at Observer.push../node_modules/#syncfusion/ej2-base/src/observer.js.Observer.notify (observer.js:89)
at PivotViewComponent.push../node_modules/#syncfusion/ej2-base/src/component.js.Component.notify (component.js:188)
at PivotViewComponent.push../node_modules/#syncfusion/ej2-pivotview/src/pivotview/base/pivotview.js.PivotView.initEngine (pivotview.js:1891)
at PivotViewComponent.push../node_modules/#syncfusion/ej2-pivotview/src/pivotview/base/pivotview.js.PivotView.executeQuery (pivotview.js:1938)
at resolvePromise (zone.js:831)
at zone.js:896
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17290)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
at invokeTask (zone.js:1744)
at XMLHttpRequest.globalZoneAwareCallback (zone.js:1770)
The weird thing about this, is that if I use a subset of the data that is coming back from the server and set it locally, it all works.
Here is an image of the request that I am making with the response and the data. I'm not sure if this is something that I can fix as this may be a bug with the DataManager.
I have tried reverting back to the previous version that I used, but there still seems to be the same problem.
We are glad to announce that our Essential Studio 2019 Volume 2 Beta Release version 17.2.0.28 is rolled out with the mentioned issue fix and is available for download under the following link.
https://www.syncfusion.com/forums/145548/essential-studio-2019-volume-2-beta-release-v17-2-0-28-is-available-for-download
Note: This issue fix will be included in our main release as well which is expected to be available by mid of July 2019.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Dinesh Babu Yadav

SailsJS 1.0 : Error in .create() for a model in Mongo with One Way Association to a model stored in MySQL

I have a Users model stored in MongoDb and a UserTypes model stored in MySQL.
When I try to create a new User:
Users.create({name: "Shivam", userType: 1})
I get following error:
{ AdapterError: Unexpected error from database adapter: Invalid replacement foreign key value provided for association (`userType`). Cannot interpret `1` as a Mongo id.
(Usually, this is the result of a bug in application logic.)
For more info on Mongo ids, see:
• https://docs.mongodb.com/manual/reference/bson-types/#objectid
• http://sailsjs.com/support
at _afterPotentiallyFinding (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-or-create.js:258:17)
at _afterPotentiallyRunningAfterLC (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-one.js:328:20)
at _maybeRunAfterLC (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-one.js:322:20)
at _afterFetchingRecords (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-one.js:324:13)
at _afterGettingPopulatedPhysicalRecords (/My_Project_Root//node_modules/waterline/lib/waterline/utils/query/help-find.js:754:12)
at /My_Project_Root//node_modules/waterline/lib/waterline/utils/query/help-find.js:151:16
at Object.success (/My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:254:18)
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1354:30
at _tryToRunCb (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:542:20)
at /My_Project_Root//node_modules/parley/lib/private/Deferred.js:755:16
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:966:24
at Function.handlerCbs.success (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:826:26)
at Object.fn (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/release-connection.js:77:18)
at wrapper (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3275:19)
at Deferred.parley.now.flaverr.name [as _handleExec] (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1068:17)
at Deferred.exec (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:679:10)
at Deferred.switch (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1306:16)
at /My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:242:92
at /My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:123:18
at Object.success (/My_Project_Root//node_modules/sails-mongo/lib/private/build-std-adapter-method.js:61:47)
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1354:30
at _tryToRunCb (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:520:18)
cause:
{ AdapterError: Unexpected error from database adapter: Invalid replacement foreign key value provided for association (`userType`). Cannot interpret `1` as a Mongo id.
(Usually, this is the result of a bug in application logic.)
For more info on Mongo ids, see:
• https://docs.mongodb.com/manual/reference/bson-types/#objectid
• http://sailsjs.com/support
at _afterPotentiallyFinding (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-or-create.js:258:17)
at _afterPotentiallyRunningAfterLC (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-one.js:328:20)
at _maybeRunAfterLC (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-one.js:322:20)
at _afterFetchingRecords (/My_Project_Root//node_modules/waterline/lib/waterline/methods/find-one.js:324:13)
at _afterGettingPopulatedPhysicalRecords (/My_Project_Root//node_modules/waterline/lib/waterline/utils/query/help-find.js:754:12)
at /My_Project_Root//node_modules/waterline/lib/waterline/utils/query/help-find.js:151:16
at Object.success (/My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:254:18)
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1354:30
at _tryToRunCb (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:542:20)
at /My_Project_Root//node_modules/parley/lib/private/Deferred.js:755:16
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:966:24
at Function.handlerCbs.success (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:826:26)
at Object.fn (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/release-connection.js:77:18)
at wrapper (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3275:19)
at Deferred.parley.now.flaverr.name [as _handleExec] (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1068:17)
at Deferred.exec (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:679:10)
at Deferred.switch (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1306:16)
at /My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:242:92
at /My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:123:18
at Object.success (/My_Project_Root//node_modules/sails-mongo/lib/private/build-std-adapter-method.js:61:47)
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1354:30
at _tryToRunCb (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:520:18)
name: 'AdapterError',
adapterMethodName: 'create',
modelIdentity: 'users',
raw:
{ Error: Invalid replacement foreign key value provided for association (`userType`). Cannot interpret `1` as a Mongo id.
(Usually, this is the result of a bug in application logic.)
For more info on Mongo ids, see:
• https://docs.mongodb.com/manual/reference/bson-types/#objectid
• http://sailsjs.com/support
at /My_Project_Root//node_modules/sails-mongo/lib/private/machines/private/reify-values-to-set.js:95:35
at /My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3253:15
at baseForOwn (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:2223:14)
at /My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3223:18
at Function.<anonymous> (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3526:13)
at reifyValuesToSet (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/private/reify-values-to-set.js:68:5)
at Object.fn (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/create-record.js:58:7)
at wrapper (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3275:19)
at Deferred.parley.now.flaverr.name [as _handleExec] (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1068:17)
at Deferred.exec (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:679:10)
at Deferred.switch (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1306:16)
at Object.during (/My_Project_Root//node_modules/sails-mongo/lib/private/build-std-adapter-method.js:74:18)
at _makeCallToDuringFn (/My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:109:17)
at /My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:128:7
at Object.success (/My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:91:16)
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1354:30
at _tryToRunCb (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:542:20)
at /My_Project_Root//node_modules/parley/lib/private/Deferred.js:755:16
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:966:24
at Function.handlerCbs.success (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:826:26)
at Object.fn (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/get-connection.js:61:18)
at wrapper (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3275:19) code: 'E_CANNOT_INTERPRET_AS_OBJECTID' } },
isOperational: true,
adapterMethodName: 'create',
modelIdentity: 'users',
raw:
{ Error: Invalid replacement foreign key value provided for association (`userType`). Cannot interpret `1` as a Mongo id.
(Usually, this is the result of a bug in application logic.)
For more info on Mongo ids, see:
• https://docs.mongodb.com/manual/reference/bson-types/#objectid
• http://sailsjs.com/support
at /My_Project_Root//node_modules/sails-mongo/lib/private/machines/private/reify-values-to-set.js:95:35
at /My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3253:15
at baseForOwn (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:2223:14)
at /My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3223:18
at Function.<anonymous> (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3526:13)
at reifyValuesToSet (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/private/reify-values-to-set.js:68:5)
at Object.fn (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/create-record.js:58:7)
at wrapper (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3275:19)
at Deferred.parley.now.flaverr.name [as _handleExec] (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1068:17)
at Deferred.exec (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:679:10)
at Deferred.switch (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1306:16)
at Object.during (/My_Project_Root//node_modules/sails-mongo/lib/private/build-std-adapter-method.js:74:18)
at _makeCallToDuringFn (/My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:109:17)
at /My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:128:7
at Object.success (/My_Project_Root//node_modules/sails-mongo/lib/private/do-with-connection.js:91:16)
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:1354:30
at _tryToRunCb (/My_Project_Root//node_modules/parley/lib/private/Deferred.js:542:20)
at /My_Project_Root//node_modules/parley/lib/private/Deferred.js:755:16
at /My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:966:24
at Function.handlerCbs.success (/My_Project_Root//node_modules/machine/lib/private/help-build-machine.js:826:26)
at Object.fn (/My_Project_Root//node_modules/sails-mongo/lib/private/machines/get-connection.js:61:18)
at wrapper (/My_Project_Root//node_modules/#sailshq/lodash/lib/index.js:3275:19)
code: 'E_CANNOT_INTERPRET_AS_OBJECTID' } }
However, .populate() works just fine:
Users.findOne('USER_ID_HERE').populate('userType')
yields the following result:
{
id: "USER_ID_HERE",
name: "Shivam",
userType: {
id: 1,
label: "Student"
}
}
Here are my Models:
Users.js:
module.exports = {
datastore: 'mongoDb',
attributes: {
id: {type: 'string', columnName: '_id', required: false},
name: {
type: 'string',
required: false,
allowNull: true,
maxLength: 50,
minLength: 3
},
userType: {model: 'usertypes', required: true},
}
};
and UserTypes.js:
module.exports = {
datastore: 'default',
attributes: {
id: {type: 'number', autoIncrement: true},
label: {
type: 'string',
maxLength: 255,
required: true,
unique: true
},
createdAt: false,
updatedAt: false,
users: {collection: 'users', via: 'userType'}
}
};
where default datastore is MySQL and mongoDb datastore is MongoDb.
Here is the version info:
Version Info:
: Sails : v1.0.2
: node : v8.1.2
: engine (v8) : 5.8.283.41
: openssl : 1.0.2l
: sails-mongo : ^1.0.1
: sails-mysql : ^1.0.0
: sails-hook-orm : ^2.0.0-16
What am I doing wrong?
For others experiencing the same issue, here is a hotfix:
Set dontUseObjectIds: true for all models using MySQL adapter.
This seems to trick the sails-mongo adapter to not check for ObjectIds for Foreign Keys to Models using sails-mysql Adapter.
Please note that this is NOT a proper solution, but just a workaround.

AppCache - manifest error (4)

I have hard time to debug why the appcache doesn't work for me. On latest chrome I have got the following errors:
Creating Application Cache with manifest http://localhost/BEST/Home/Manifest
(index):1 Application Cache Checking event
(index):1 Application Cache Error event: Manifest fetch failed (4) http://localhost/BEST/Home/Manifest
More specific (from onerror method):
ApplicationCacheErrorEvent {
message: "Manifest fetch failed (4) http://localhost/BEST/Home/Manifest",
status: 4294967295,
url: "http://localhost/BEST/Home/Manifest",
reason: "manifest",
clipboardData: undefined…}
bubbles: false
cancelBubble: false
cancelable: false
clipboardData: undefined
currentTarget: ApplicationCache
defaultPrevented: false
eventPhase: 0
message: "Manifest fetch failed (4) http://localhost/BEST/Home/Manifest"
path: NodeList[0]
reason: "manifest"
returnValue: true
srcElement: ApplicationCache
oncached: null
onchecking: null
ondownloading: null
onerror: function (a,b,c)
onnoupdate: null
onobsolete: null
onprogress: null
onupdateready: null
status: 0
__proto__: ApplicationCache
status: 4294967295
target: ApplicationCache
oncached: null
onchecking: null
ondownloading: null
onerror: function (a,b,c)
onnoupdate: null
onobsolete: null
onprogress: null
onupdateready: nullstatus: 0
__proto__: ApplicationCache
timeStamp: 1425021666357
type: "error"
url: "http://localhost/BEST/Home/Manifest"
__proto__: ApplicationCacheErrorEvent
My manifest is very simple:
CACHE MANIFEST
CACHE:
Content/DataTables-1.10.3/language/polish.json
NETWORK:
*
Even the manifesto didn't help
Manifest file is served by ASP.NET MVC action, but doesn't matter I think.
Just in case the code:
public ActionResult Manifest()
{
//Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
var text = System.IO.File.ReadAllText(HttpContext.Server.MapPath("../a.appcache"));
return new ContentResult()
{
ContentType = "text/cache-manifest",
Content = text,
ContentEncoding = System.Text.Encoding.UTF8
};
}
[edit]
On Safari on Win I got
Application Cache manifest could not be fetched, because a redirection was attempted.
Maybe here is a problem?
This is what I got from fiddler attached to chrome:
I see, there is a 302, but could it be the problem?
And I doesn't know how to change it to 200.
[edit2]
I set manually the status code in the Manifest action and it started to work:
public ActionResult Manifest()
{
//Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
var text = System.IO.File.ReadAllText(HttpContext.Server.MapPath("../BEST.appcache"));
Response.StatusCode = 200;
return new ContentResult()
{
ContentType = "text/cache-manifest",
Content = text,
ContentEncoding = System.Text.Encoding.UTF8
};
}
But only temporary... After few tests, now I got different error. The reason this time is set to signature, not manifest:
Application Cache Error event: Failed to parse manifest http://localhost/BEST/Home/Manifest
(index):252
ApplicationCacheErrorEvent {
message: "Failed to parse manifest http://localhost/BEST/Home/Manifest",
status: 0,
url: "",
reason: "signature",
clipboardData: undefined…}
bubbles: false
cancelBubble: false
cancelable: false
clipboardData: undefined
currentTarget: ApplicationCache
defaultPrevented: false
eventPhase: 0
message: "Failed to parse manifest http://localhost/BEST/Home/Manifest"
path: NodeList[0]
reason: "signature"
returnValue: true
srcElement: ApplicationCache
status: 0
target: ApplicationCache
timeStamp: 1425025030583
type: "error"
url: ""
__proto__: ApplicationCacheErrorEvent
The solution was to set the status code to 200 and the no-store header couldn't be defined.