Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
Issue Description
When using the AsyncStorage backend for react-native
, you would get Unhandled promise rejection: TypeError: this.getAsyncStorage is not a function.
when trying to save objects.
Inspecting the distribution file node_modules/parse/lib/react-native/StorageController.react-native.js
shows that all arrow functions have been transformed into regular functions, causing the this
context to become ones of the callback functions and making everything break.
Replacing all the unnamed functions with arrow functions as originally written in the source restores the same, functioning behaviour.
This appears to be a problem with the babel transpiler during the publish process (the file clearly has _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
at the top).
Steps to reproduce
- Install
[email protected]
into a react native project. - Configure Parse to use AsyncStorage backend
import AsyncStorage from '@react-native-async-storage/async-storage';
Parse.setAsyncStorage(AsyncStorage);
- Try creating a new Parse.Object
- Call
await object.save()
orawait object.saveEventually()
on the object
Actual Outcome
[Unhandled promise rejection: TypeError: this.getAsyncStorage is not a function. (In 'this.getAsyncStorage()', 'this.getAsyncStorage' is undefined)]
- This can be fixed by manually going into the
node_modules/parse/lib/react-native/StorageController.react-native.js
and replacing all the unnamed functions with arrow functions as originally written in the source restores the same, functioning behaviour.
Expected Outcome
- The object gets saved normally.
Environment
Server
- Parse Server version:
5.2.8
- Operating system:
Mac OS 12.4
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local host
Client
- Parse JS SDK version:
3.5.0-alpha.6
Logs
[Unhandled promise rejection: TypeError: this.getAsyncStorage is not a function. (In 'this.getAsyncStorage()', 'this.getAsyncStorage' is undefined)]
at node_modules/parse/lib/react-native/StorageController.react-native.js:12:26 in Promise$argument_0
at node_modules/parse/lib/react-native/StorageController.react-native.js:11:22 in getItemAsync
at node_modules/parse/lib/react-native/Storage.js:24:36 in getItemAsync
at node_modules/parse/lib/react-native/EventuallyQueue.js:435:40 in load
at node_modules/parse/lib/react-native/EventuallyQueue.js:449:56 in _regeneratorRuntime.async$argument_0
at node_modules/parse/lib/react-native/EventuallyQueue.js:96:20 in tryCatch
at node_modules/parse/lib/react-native/EventuallyQueue.js:76:31 in <anonymous>
at node_modules/parse/lib/react-native/EventuallyQueue.js:96:20 in tryCatch
at node_modules/parse/lib/react-native/EventuallyQueue.js:134:27 in invoke
at node_modules/parse/lib/react-native/EventuallyQueue.js:158:16 in PromiseImpl$argument_0
at node_modules/parse/lib/react-native/EventuallyQueue.js:157:30 in callInvokeWithMethodAndArg
at node_modules/parse/lib/react-native/EventuallyQueue.js:162:154 in _invoke
at node_modules/parse/lib/react-native/EventuallyQueue.js:248:66 in exports.async
at node_modules/parse/lib/react-native/EventuallyQueue.js:438:38 in getQueue
at node_modules/parse/lib/react-native/EventuallyQueue.js:525:60 in _regeneratorRuntime.async$argument_0
at node_modules/parse/lib/react-native/EventuallyQueue.js:96:20 in tryCatch
at node_modules/parse/lib/react-native/EventuallyQueue.js:76:31 in <anonymous>
at node_modules/parse/lib/react-native/EventuallyQueue.js:96:20 in tryCatch
at node_modules/parse/lib/react-native/EventuallyQueue.js:134:27 in invoke
at node_modules/parse/lib/react-native/EventuallyQueue.js:158:16 in PromiseImpl$argument_0
at node_modules/parse/lib/react-native/EventuallyQueue.js:157:30 in callInvokeWithMethodAndArg
at node_modules/parse/lib/react-native/EventuallyQueue.js:162:154 in _invoke
at node_modules/parse/lib/react-native/EventuallyQueue.js:248:66 in exports.async
at node_modules/parse/lib/react-native/EventuallyQueue.js:520:38 in length