-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: Capacitor androidBridge.postMessage converting null
to "..."
#4798
Comments
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue. Please see the Contributing Guide for how to create a Code Reproduction. Thanks! |
paste this into console (this is the method used to post data to native android): const safeStringify = (value) => {
const seen = new Set();
return JSON.stringify(value, (_k, v) => {
if (seen.has(v)) {
return '...';
}
if (typeof v === 'object') {
seen.add(v);
}
return v;
});
};
safeStringify([null,null]);
// output: "[null,\"...\"]" |
Sorry, I still need an app where it can be reproduced |
ok, someone posted one in the original issue: https://github.com/gabrielcursino/capacitor-sqlite-test however i think you might save some time by just running the method directly, since it is obviously treating |
@jcesarmobile @chriswep you can find the app to reproduce the issue |
@jcesarmobile @chriswep seems that if you modify in assets/native-bridge.js the constant const safeStringify = (value) => {
const seen = new Set();
return JSON.stringify(value, (_k, v) => {
if (typeof v === 'object') {
seen.add(v);
}
return v;
});
}; it works , but i do not know what is the impact of doing that on the rest of the code and what the reason to have these lines if (seen.has(v)) {
return '...';
} Hope this will help |
@jepiqueau the purpose of the method is to remove circular references in an object since |
@chriswep your proposed fix is working Any progress status from @jcesaremobile |
same problem, two days lost ... and there is no way to solve it because it is the base framework |
@emirtb I am sorry for this time lost but there is nothing I can do it is in the hands of the Ionic Capacitor team |
To modify this file as a workaround, where is it located? in the node_modules? Thanks |
@elylucas @thomasvidas @chriswep Seems it is always there in 3.1.2 despite the Changelog.md core: Modify safeStringify to allow multiple null values (#4853) (854539b). If i look in https://github.com/ionic-team/capacitor/blob/main/android/capacitor/src/main/assets/native-bridge.js it is still const safeStringify = (value) => {
const seen = new Set();
return JSON.stringify(value, (_k, v) => {
if (seen.has(v)) {
return '...';
}
if (typeof v === 'object') {
seen.add(v);
}
return v;
});
}; and not the proposed solution by @thomasvidas |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
originally posted here but closed due to inactivity: #4746
the method
safeStringify
incapacitor/android/capacitor/src/main/assets/native-bridge.js
Line 175 in 0429905
null
values when checking for circular references (null
has the typeobject
as well). therefore[10,null,null,null]
is converted to[10,null,'...','...']
(as posted in the original issue).bug was introduced here: 0429905#diff-8afda3e2bce7fb91a14a66d96d63a89f112b852cf39223e6f820a1575cbdafebR175
The text was updated successfully, but these errors were encountered: