Why does getEntry yield a warning: modalBehavior with wait is not supported

Hi,
I am trying to access a subfolder using getPluginFolder
I use:

const fs = require('uxp').storage.localFileSystem;
const pluginFolder = await fs.getPluginFolder();
const myFile = await pluginFolder.getEntry("assets\\myFile.psd");

assets\myFile.psd exists and myFile is a file which I can open.
Everything works.
What bothers me is the following warning in the debugger.
modalBehavior with wait is not supported while the plugin is inside a modal scope
_internalLogMessageWrapper @ VM27 common.js:100
image
I appears when I step over the last line in teh above code, the one which gets the entry.

Should I fix it and if yes what should I change?

You can’t use

{modalBehavior: "wait"}

if you’re already inside

require('photoshop').core.executeAsModal();

Try using

{}

instead.

{modalBehavior: "wait"} is part of batchplay function, is it not?
The code in my question uses existing API methods.

I can’t change anything there.

Yes, it’s part of batchPlay, but the error you show in your original message strongly suggests it’s in your code somewhere. Try doing a search for it and seeing what you find.

I use the debugger and step over each of the 3 commands below.

1) const fs = require('uxp').storage.localFileSystem;
2) const pluginFolder = await fs.getPluginFolder();
3) const myFile = await pluginFolder.getEntry("assets\\myFile.psd");

That warning is when stepping over line 3.
There is no additional code between them.

Your error message indicates it’s on line 100 of your JS, not lines 121 and 122.

100 on common.js which is not my file.
BTW, why can’t i see, on the debugger, the inner errors which are thrown by the built in files?
I can only detect them when I step into those function and place my cursor over the try/catch part with the error,
E.g. to make sure these error are printed to log/debugger console without the need to step into?

I believe you should see a returned rejected promise with an error from executeAsModal() in the console if you log it

const result = executeAsModal()
console.log(result)

Thank you,
I guess I could add, to my batchplay function, console.log(..
To track errors in my code is easier, however if the error is generated elsewhere, how can I make sure they are printed without the need to add the console.log to every line in my code?
E.g. take
$("#btnPopulate").click(function(){showLayerNames()});
If the id, btnPopulate in this case, does not exist, I only see the error if I step into the above line in the debugger.
Isn’t there a way, for debugging, to always print to log the result of executionControl.reject(error)?

You could write your own wrapper function, add logging there and use it instead of Ps executeAsModal(). Something like:

const execModal = (func) => {
  require('photoshop')
    .core
    .executeAsModal(func)
    .then(result => console.log(result))
    .catch(error => console.log(error))
}
1 Like

Thanks, This may show any errors inside any executeAsModal…
It will not however, show errors related not executeAsModal like example above.

Not sure what are you looking for. In this case it’s your code/approach is faulty and you get errors arising from your code and not executeAsModal() specifically. And you shouldn’t, because in this case executeAsModal() is working fine. Why do you expect some other error than the one produced because of your code? Or am I missing a point here?

The suggestion to add console.log to my function helped.
My question regarding showing errors which are not related to my function is something I came across when I tried to find the problem in my code.

I gave an example, showing that, in other cases, if I make a mistake and try to access a non existing ID, I would expect to get an error or warning whereas the log does not show anything.