mirror of
https://github.com/ProxymanApp/Proxyman.git
synced 2026-04-27 17:15:49 +03:00
[GH-ISSUE #1420] Invalid Promise object in Script runner breaks require of full lodash suite #1413
Labels
No labels
Discussion
Feature request
In Progress...
Plugins
Waiting response
Windows
Windows
bug
duplicate
enhancement
feature
good first issue
iOS
macOS 10.11
question
wontfix
✅ Done
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Proxyman#1413
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rolfb on GitHub (Oct 27, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1420
Originally assigned to: @NghiaTranUIT on GitHub.
Description
The Promise object in the Script runner does not support Promise.resolve.
The solution is either to remove the invalid Promise object or implement full support.
Uncomment the code in the example script below to watch it run correctly.
Steps to Reproduce
Current Behavior
Lodash fails to load because Promise.resolve doesn't exist with error: "[...].resolve is not a function"
Expected Behavior
It should have executed and logged the value
3to the consoleEnvironment
@NghiaTranUIT commented on GitHub (Oct 27, 2022):
Not sure if you use
asyncon the script? async/await has been supported on the latest Proxyman.Ref: https://docs.proxyman.io/scripting/async-await-request
The
lodashlibrary has been bundled to the app too. Ref: https://docs.proxyman.io/scripting/built-in-js-librariesYou can simply use it:
As far as I remember, I need to modify the lib to make it works with the Scripting. It's built on top of JavaScriptCore framework from Apple, so it might not fully work like the JS env on the Web Browser.
@rolfb commented on GitHub (Oct 27, 2022):
The built-in version of lodash is a subset (just core) and missing a lot. An example is
_.get, but there are plenty more.The example reproduction script does not use any async/await features. The problem lies with libraries that checks if Promise exists and then tries to wrap it internally such as lodash utility functions, and the Proxyman Script Runner provides a faked or functionally impaired Promise object which fools guard clauses.
@rolfb commented on GitHub (Oct 27, 2022):
@NghiaTranUIT isn't all of the Promise API supported by JavascriptCore by default?
@NghiaTranUIT commented on GitHub (Oct 28, 2022):
It supports Promise, but not fully. From what I experience, I have to implement methods to make Promise work.
@rolfb commented on GitHub (Oct 28, 2022):
I propose either to remove the Promise object or make Promise.resolve work to avoid confusion.
Here's an example snippet you can run and re-run to verify:
By the way, forgot to mention I really like the app. Thank you :)
@NghiaTranUIT commented on GitHub (Oct 29, 2022):
Thanks. I will look into it. The reason why we introduce the Customize Promise is that we've implemented the
await $http.get(). JavascriptCore doesn't work well with the JS Promise mechanism. (Or maybe I'm doing wrong 🧐)@rolfb commented on GitHub (Oct 31, 2022):
I'm not sure, but Promise.resolve is available in my local
jschelper so the code example below works.On a Mac you can launch it using this command in the terminal:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc@StanislavMayorov commented on GitHub (Dec 16, 2023):
@NghiaTranUIT HI. It's very confusing that build-in lodash contains only 10 of 200 functions. Could you fix it and add full lodash please?
Current lodash version
Build: lodash include="camelCase,deburr,escapeRegExp,kebabCase,snakeCase,startCase,". Proxyman version 4.15.0.@NghiaTranUIT commented on GitHub (Dec 17, 2023):
@StanislavMayorov let's me update to the latest lodash and share with you a Beta build 👍
@StanislavMayorov commented on GitHub (Dec 17, 2023):
@NghiaTranUIT many thanks!
@NghiaTranUIT commented on GitHub (Dec 18, 2023):
cc @StanislavMayorov : You can try this Beta build
cc @rolfb : Sorry that this bug takes so long to fix. It's finally fixed on the Beta build.
Changelog
How to use
lodash.jsfirst at~/Library/Application Support/com.proxyman.NSProxy/addons/libs/lodash.js(On the production build, this step is not required)Here is the script I tested:
@StanislavMayorov commented on GitHub (Dec 18, 2023):
@NghiaTranUIT great! thank you. Now
_.getand_.cloneDeepworks.@StanislavMayorov commented on GitHub (Dec 18, 2023):
I don't know if it's for purpose or not in the docs
const Lodash = require('@libs/lodash.js'), but common usage is underscore for lodashconst _ = require('@libs/lodash.js').@NghiaTranUIT commented on GitHub (Dec 19, 2023):
Awesome. Glad to know it works 😄
You're right, I will update the docs to use the
_👍