[go: up one dir, main page]

Skip to content

node.js custom hook fails on fs.write

Custom hooks written in node.js fail with a strange error when using fs.write. Also other things don't work either, i.e. node-java.

Replicating the issue is easy. Use a sample pre-receive hook written in node.js located at /var/opt/gitlab/git-data/repositories/<group>/<repo>.git/custom_hooks/pre-receive that simply writes to a file:

#!/usr/bin/env node

var fs = require('fs');
var path = require('path');

fs.open('test-fs-write.node.txt', 'w', function(err, fd) {
  if (err) throw err;
  fs.write(fd, "test node fs.write\n", function(err) {});
});

This fails with:

fs.js:513
  binding.write(fd, buffer, offset, length, position, wrapper);
          ^
TypeError: Not an integer
    at Object.fs.write (fs.js:513:11)
    at /var/opt/gitlab/git-data/repositories/group/repo.git/custom_hooks/pre-receive:10:6
    at Object.oncomplete (fs.js:107:15)

Environment: Ubuntu 14.04.3 LTS, node 0.12.7, GitLab 7.13.5, GitLab Shell 2.6.3, Ruby 2.1.6p336, Rails 4.1.11.