My learning diary

reCaptcha on-error

Polling wasn’t effective because:

  1. Hot reloading didn’t happen because of some heap limit error.
  2. I called the wrong function to check if the reCaptcha errored.

To deal with the heap limit, my buddy suggested updating the docker-dev script in package.json to:

{
  "scripts": {
    "docker-dev": "export NODE_OPTIONS=\"--max-old-space-size=4096\" && ..."
  }
}

As for checking if the reCaptcha errored, neither on-expire nor captchaService.isValid worked. A possible explanation for the former would be that the reCaptcha didn’t expire. It just didn’t work. On the other hand, captchaService.isValid checks this.response || !this.enabled. These don’t determine if the reCaptcha errored.

My buddy wondered if there was something like on-error. He dug through the reCaptcha package’s source code and found it in the directive. This jewel wasn’t documented. I proceeded to use on-error with much success!

Relevant posts