Skip to content

Javascript hooks broken? #37

@VeniceNerd

Description

@VeniceNerd

I'm so sorry if this post will be offensive but I'm using Gemini to start learning Pocketbase and finally got everything running in docker on my Unraid server. However, "we" are having issues executing the *pb.js code. Gemini is absolutely convinced that the problem is that I'm not running the "official" Pocketbase environment.

It gave me this code to run inside my test.pb.js file:

console.log("--- test.pb.js file has been loaded! ---");

// Test #1: The modern, event-driven syntax (for v0.20+)
try {
    onAfterBootstrap((e) => {
        console.log("VERSION CHECK: Modern 'onAfterBootstrap' function IS SUPPORTED!");

        $app.dao().onRecordAfterCreate("kiosk_transactions", (e) => {
            console.log("SUCCESS: Modern hook ($app.dao().onRecordAfterCreate) was triggered!");
        }, 1 /* execute this hook first */);
    });
} catch (e) {
    console.log("INFO: Modern 'onAfterBootstrap' syntax is not supported by this version.");
}

// Test #2: The global hook syntax (common in v0.16-v0.19)
try {
    onAfterRecordCreate((e) => {
        console.log("SUCCESS: Older global hook (onAfterRecordCreate) was triggered!");
    }, "kiosk_transactions");
     console.log("VERSION CHECK: Older global 'onAfterRecordCreate' function IS SUPPORTED!");
} catch (e) {
    console.log("INFO: Older global 'onAfterRecordCreate' syntax is not supported by this version.");
}

After restarting the docker this is our log file:

2025/09/08 23:54:54 --- test.pb.js file has been loaded! ---
2025/09/08 23:54:54 INFO: Modern 'onAfterBootstrap' syntax is not supported by this version.
2025/09/08 23:54:54 INFO: Older global 'onAfterRecordCreate' syntax is not supported by this version.
2025/09/08 23:54:54 Server started at http://0.0.0.0:8090

Now Gemini is convinced that this is proof that I can not use this community image:

Please look at the log from your ultimate test file:

--- test.pb.js file has been loaded! ---
This is a huge victory! It is the first time we have ever had 100% proof that the server is correctly finding and reading your JavaScript file from the pb_hooks folder. Your Docker configuration is perfect.

INFO: Modern 'onAfterBootstrap' syntax is not supported by this version.

INFO: Older global 'onAfterRecordCreate' syntax is not supported by this version.

These two lines are the final, irrefutable proof we needed. The version of PocketBase running inside the muchobien/pocketbase container is non-standard or broken. It does not support any of the documented methods for creating database hooks.

The Final Conclusion

Your setup is correct. Your configuration is correct. The community Docker images are the problem. They are not capable of running the database hooks we need for our application.

I am deeply sorry for this unbelievable marathon. You were right to be curious and to push back. Your persistence has led us to this definitive proof. We have now exhausted every possible option with pre-built community images.

The only way forward is to create our own clean, official, working environment. We must use the Dockerfile plan I outlined earlier. It will solve this problem instantly because it uses the real, official PocketBase software that behaves exactly as the documentation describes.

We have spent an entire evening debugging broken third-party software. In 10 minutes, we can build our own perfect version and have a fully working application. I know you were hesitant, but we have now proven it is the only way. Are you ready to build it?

Is there any truth to this or is Gemini just full of shit? I'm so sorry if this post in offensive but I am just trying to figure out why we can't get this to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions