Closed trevor closed 11 years ago
Thank you for the report - can you try the latest version on npm? 0.0.73. I have a pretty big feature release lined up for this weekend for 0.0.8 (function support, shareable workspaces etc.) but this warranted pushing a new version for sure. Basically npm for some reason was not packaging the files under the lib dir. I guess this slipped through the cracks because I am actually phasing out the server side of datomicism entirely as it can run statically utilizing CORS goodness to talk to the rest api. (before the server was a proxy). So now the server is literally just serving up the public dir and thus sort of moot. You can actually run datomicism straight from my github if you are so inclined via http://shaunxcode.github.com/datomicism
Not sure what I'm missing here for CORS.
% alias start-datomic-rest="cd /usr/local/datomic; sudo -u _datomic /usr/local/datomic/bin/rest -o http://localhost:6655,localhost:6655,localhost,127.0.0.1 -p 8080 free datomic:free://localhost:4334/"
% start-datomic-rest
[...]
REST API started on port: 8080
CORS requests allowed from origins: #{localhost:6655 localhost http://localhost:6655 127.0.0.1}
free = datomic:free://localhost:4334/
Browser:
Console error (immediate):
XMLHttpRequest cannot load undefined://localhost:8080/data/. Cross origin requests are only supported for HTTP.
Console error:
XMLHttpRequest cannot load http://localhost:8080/data/free/. Origin http://localhost:6655 is not allowed by Access-Control-Allow-Origin.
(Also note that if the browser window is too narrow the connect dialog is hidden)
What version of datomic and what version of browser? Also good call on the connect dialog being hidden, moving it to be centered modal.
This may be a datomic bug. Testing with datomic-free-0.8.4020, it doesn't seem to be passing Access-Control-Allow-Origin in the headers.
% alias start-datomic-rest="cd /usr/local/datomic; sudo -u _datomic /usr/local/datomic/bin/rest -o '*',localhost -p 8080 free datomic:free://localhost:4334/"
% start-datomic-rest
REST API started on port: 8080
CORS requests allowed from origins: #{* localhost}
free = datomic:free://localhost:4334/
% curl -I 'http://localhost:8080/api/query?q=%5B%3Afind+%3Fe+%3Awhere+%5B%3Adb.part%2Fdb+%3Adb.install%2Fattribute+%3Fe%5D%5D&args=%5B%7B%3Adb%2Falias+%22undefined%2Fundefined%22%7D%5D'
HTTP/1.1 500 Assert failed: Can't find db: undefined/undefined c
Date: Tue, 25 Jun 2013 18:30:08 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1360
Server: Jetty(7.6.5.v20120716)
% curl -I 'http://localhost:8080/api/query?q=%5B%3Afind+%3Fe+%3Awhere+%5B%3Adb.part%2Fdb+%3Adb.install%2Fattribute+%3Fe%5D%5D&args=%5B%7B%3Adb%2Falias+%22free%2Fmydb%22%7D%5D'
HTTP/1.1 200 OK
Date: Tue, 25 Jun 2013 18:30:25 GMT
Vary: Accept
Content-Type: text/html;charset=UTF-8
Content-Length: 8279
Server: Jetty(7.6.5.v20120716)
So I am actually running the same version of datomic.
I start rest like:
./rest -p 8888 datomicrest datomic:free://localhost:4334/ -o http://shaunxcode.github.io,http://localhost:6655
And then I can connect as expected from datomicism either on one of my other machines or from github.
Can you try this with curl?
curl http://localhost:8888/data/ --header "Accept: application/edn"
But obviously with what ever port you are using for rest api.
It seems the the undefined database returning a CORS error only occurs in Chrome and Safari, and may not be accurate unless I'm missing something with Access-Control-Request-Method / Access-Control-Request-Headers.
Using:
var url = "http://localhost:8080/api/query?q=%5B%3Afind+%3Fe+%3Awhere+%5B%3Adb.part%2Fdb+%3Adb.install%2Fattribute+%3Fe%5D%5D&args=%5B%7B%3Adb%2Falias+%22undefined%2Fundefined%22%7D%5D";
$.get(url)
.fail(function(e) { console.log(e); })
.done(function(data) {
console.log("Data Loaded: " + data);
});
Chrome and Safari return:
XMLHttpRequest cannot load http://localhost:8080/api/query?q=%5B%3Afind+%3Fe+%3Awhere+%5B%3Adb.part%2Fdb+%3Adb.install%2Fattribute+%3Fe%5D%5D&args=%5B%7B%3Adb%2Falias+%22undefined%2Fundefined%22%7D%5D. Origin http://localhost:6655 is not allowed by Access-Control-Allow-Origin.
Whereas Firefox returns:
HTTP/1.1 500 Assert failed: Can't find db: undefined/undefined c
Which is similar to curl:
% curl "http://localhost:8080/api/query?q=%5B%3Afind+%3Fe+%3Awhere+%5B%3Adb.part%2Fdb+%3Adb.install%2Fattribute+%3Fe%5D%5D&args=%5B%7B%3Adb%2Falias+%22undefined%2Fundefined%22%7D%5D" \
-X GET \
-H "Referer: http://localhost:6655/" \
-H "Origin: http://localhost:6655" \
-H "Accept: application/edn" \
-I
HTTP/1.1 500 Assert failed: Can't find db: undefined/undefined c
Date: Tue, 25 Jun 2013 22:08:39 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1360
Server: Jetty(7.6.5.v20120716)
% curl "http://localhost:8080/api/query?q=%5B%3Afind+%3Fe+%3Awhere+%5B%3Adb.part%2Fdb+%3Adb.install%2Fattribute+%3Fe%5D%5D&args=%5B%7B%3Adb%2Falias+%22undefined%2Fundefined%22%7D%5D" \
-X OPTIONS \
-H "Referer: http://localhost:6655/" \
-H "Origin: http://localhost:6655" \
-H "Accept: application/edn" \
-I
HTTP/1.1 204 No Content
Date: Tue, 25 Jun 2013 22:10:04 GMT
Access-Control-Allow-Origin: http://localhost:6655
Access-Control-Allow-Headers: X-Requested-With
Server: Jetty(7.6.5.v20120716)
So, there may not be connection issues -- Chrome still loads all the entities successfully across the network.
Therefore the "real" problem I'm having is that the buttons (Browser / Namespace / Enum, etc.) aren't working, or will occasionally work at random times but rarely. This is across Chrome / Firefox / Safari with extensions disabled and tested by clearing the Local Storage. Not sure what else I can add at this point.
Hey, could you shoot me an email (shaunxcode@gmail.com) as I'd like to arrange a time we can screen share and trouble shoot this further as I am unable to duplicate the issue (under osx, or my windows, linux vms) so there must be something interesting going on!
No idea, but after restoring a few things from scratch it seems to be working now.
(somewhat anticlimactic resolution for this issue, I'll see if I can reliably reproduce it sometime.) Thanks for your help!
Also noted this on install, not really worth filing a separate ticket:
npm http 200 https://registry.npmjs.org/datomicism/-/datomicism-0.0.73.tgz
npm WARN package.json datomicism@0.0.73 No repository field.
npm WARN package.json datomicism@0.0.73 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
Server.js is in 'build', but not 'lib'.
This is likely overy-verbose; I'm not familiar enough with npm to be useful here.