iceddev / node-chromify

Entry point to use node in chrome
http://blog.iceddev.com/2012/11/05/node-js-in-chrome/
Apache License 2.0
170 stars 23 forks source link

TypeError - no method '_extend' when trying to http.get #5

Closed pecord closed 11 years ago

pecord commented 11 years ago

I added the code below to the start of the http example and it threw " Uncaught TypeError: Object # has no method '_extend' ". Got the code from the node documentation, http://nodejs.org/api/http.html#http_http_get_options_callback

var http = require('http');
//Added this code
http.get("http://www.google.com/index.html", function(res) {
  console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});
//Code add end

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello world');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

stacktrace.PNG

pecord commented 11 years ago

So i replaced the line that was giving me trouble

var options = util._extend({}, self.options); 

in node.js:line 4573 with

var options = self.options;

It got farther but still failed, this time it threw "Uncaught TypeError: Property 'INIT_RESPONSE' of object # is not a function". Firstly, any idea why underscore.js isn't loaded when it hits the options call above? Secondly the error i'm getting now appears to be related to the HTTPParser library not having an init_response method.

Capture.PNG

phated commented 11 years ago

None of the stuff to make request has even been worked on. Underscore.js isn't what you are looking for because it is Node core. HTTPParser isn't fully implemented either, as we just got enough to handle incoming requests.

pecord commented 11 years ago

I kind of assumed it was not fully implemented yet, still figured I should document it. I really like this project idea by the way, i'm a big proponent of the idea of self-hosted and P2P web apps.

phated commented 11 years ago

Yeah, good to document. The work should be done in the separate repos, though. I have found that most problems have arisen from the net-chromify and http-parser-js libraries since they were completely implemented. http-chromify is essentially a copy of node's http.js with just a few changes to avoid native calls.

sandipchitale commented 11 years ago

I ran into exactly same issue. I am trying to implement a proxy HTTP server which will serve files contained in a Chrome packaged app itself by accessing them using the http://developer.chrome.com/apps/runtime.html#method-getURL API.

phated commented 11 years ago

This project was just a proof of concept and shouldn't be used for actual projects. Someone released a better version that uses node bindings at https://npmjs.org/package/chromify which should probably be used for your project.