[BUG] [CRITICAL] UserInfo.userId() does not always return a value

In my index file, right after entrypoints.setup() I perform some checks and it’s using:

import { userInfo } from "uxp"

const userId = userInfo.userId()

Very (and I mean VERY) often userInfo.userId() returns just an empty value. Don’t know if it’s null or undefined or just empty string, but it evaluates to empty string. I spent 3 days debugging this and the only way I could pin point to this, was by adding logging to file and restart Ps a bunch of times (usually up to 10 is enough) to find this empty. Could never reproduce when loaded via UXP Dev Tools (because plugin unloads when Ps is closed), so had to actually install CCX via CCD app


Some context… My license activations are validated against OS data and this user ID. At the end I have a string similar to:

// `${some_os_data}_{userInfo.userId()}`
const validateString = "16_win32_x64_OSUsername_abcde0123456789"

And with my logging enabled I usually get this string logged as expected, but quite often it’s just:

const validateString = "16_win32_x64_OSUsername_"

If you’re using CommonJS to invoke userId(), try switching to ES modules it might improve retrieval speed. I used to get the same error, because I preform a network request that contains the userId when plugin first loads. Since switching to ES modules, everything has been working smoothly.

I don’t think I can easily switch to ES Modules now, but not sure… I’d need to check that, because everywhere in my cone I use export/import, which I believe is ES module way, but in tsconfig I have

{
  "compilerOptions": {
    "target": "es6",
    "jsx": "preserve",
    "module": "commonjs",
    "moduleResolution": "node",

Just switching it there, ends up in a bunch of errors.

In any case, I think that’s still abug :confused:

So I had this issue, exactly as you describe (uxp tool vs loading plugin) and realized it wasn’t available when my plugin first loads. I just do a check if userId exists and if not, reload until it does.

It’s definitely not an ideal solution, but it helped me.

1 Like

I had similar troubles with ExtendScript accessing InDesign’s app.userAdobeId during startup. First observed with version 19 aka 2024. The license activation may have been turned into a background task or kicks in later than in older versions.

There also have been reports about the related GUID being not distinct in school lab scenarios. I don’t know what that means for the user ID, but better prepare a timeout and some UI.

1 Like