buffer,n-api: fix double ArrayBuffer::Detach() during cleanup
These calls could fail if the ArrayBuffer
had already been explicitly
detached at some point in the past.
The necessary test changes already came with 4f523c2c and could be ported back to v12.x with a backport of this PR.
Fixes: https://github.com/nodejs/node/issues/33022 Refs: https://github.com/nodejs/node/pull/30551
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines