0

I wanted to launch GWT SuperDevMode and set breakpoints on Chrome or Edge's DevTools, but previously I was able to view the source and set breakpoints. However, the source is not displayed due to recent browser updates.

for local startup

Web container: http://127.0.0.1:8888/
souecemap: http://127.0.0.1:9876/

So it's a cross-origin, but when I check it with Chrome's DevTools,

DevTools failed to load source map: Could not load content for http://127.0.0.1:8888/sourcemaps/GwtModule/gwtSourceMap.json: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

is displayed in the console as a warning.

However, the source map specification is

//# sourceMappingURL=http://127.0.0.1:9876/sourcemaps/GwtModule/gwtSourceMap.json

It states. Therefore, it seems that the port specification is forcibly rewritten(9876->8888) by the browser.

Is this behavior due to security enhancements? Or is it just a bug?

powtok
  • 11
  • 1
  • 7
  • `source is not displayed`? Does it mean [this](https://i.stack.imgur.com/L9bpm.png) in Devtools? If this is the case, what is the version of Microsoft Edge? – Xudong Peng Jun 16 '23 at 09:42
  • Microsoft Edge version : 114.0.1823.55 64bit – powtok Jun 20 '23 at 02:31
  • Chrome version: 114.0.5735.134 64bit – powtok Jun 20 '23 at 02:32
  • For the time being, I was able to deal with it by adding a custom proxy filter to get sourcemap access from another origin in GWT JettyLauncher.java. However, I would like to know if there was a security update that allowed sourcemap to be obtained only from the same origin, or if it was a simple browser DevTools bug. – powtok Jun 20 '23 at 02:36
  • When I tried with simple source maps (chart.umd.min.js, chart.umd.js.map) using web container origin and sourmap origin, cross-origin worked fine. Apparently, in GWT2.6, when sourceMappingURL and sourceURL are specified, the port becomes port 8888 of the web container origin. If you delete the sourceURL specification, the source will be displayed without problems. This was not a problem until now, so it seems that a latent bug in GWT2.6 has surfaced with the browser version upgrade. – powtok Jun 20 '23 at 07:53
  • //# sourceMappingURL=http://127.0.0.1:9876/sourcemaps/GwtModule/gwtSourceMap.json – powtok Jun 20 '23 at 07:53
  • //# sourceURL=GwtModule-0.js – powtok Jun 20 '23 at 07:53
  • It looks like a niche problem in GWT2.6, but it would be helpful if you could give other advice. – powtok Jun 20 '23 at 07:58
  • If there is nothing in particular, I would like to post an interim solution. – powtok Jun 20 '23 at 08:00
  • If this is the case, I'm afraid I can't give good advice since I don't know GWT very well. If you have a solution for this issue, you can post it, it will also help others in the community with similar problems. – Xudong Peng Jun 20 '23 at 08:18
  • I will post about the solution for now. – powtok Jun 21 '23 at 00:38

1 Answers1

0

This issue was in GWT2.6.1 and may have been resolved in later versions. In order to deal with GWT2.6.1, customize JettyLauncher.java in gwt-dev.jar to retrieve and return port 9999 origin via Filter for sourcemap request of port 8888 origin, and add that class to project You can deal with it by placing it in src and using it.

com.google.gwt.dev.shell.jetty.JettyLauncher.java (custom. Added wac.addFilter() )

  protected JettyServletContainer createServletContainer(TreeLogger logger,
      File appRootDir, Server server, WebAppContext wac, int localPort) {
      wac.addFilter(SourcemapFilter.class, "/sourcemaps/GwtModule/gwtSourceMap.json", EnumSet.of(DispatcherType.INCLUDE,DispatcherType.REQUEST));
      return new JettyServletContainer(logger, server, wac, localPort, appRootDir);
  }

com.google.gwt.dev.shell.jetty.SourcemapFilter.java (custom. new class )

public class SourcemapFilter implements Filter {

    @SuppressWarnings("unused")
    @Override
    public void init(FilterConfig arg0) throws ServletException {
        // noop
    }

    @SuppressWarnings("unused")
    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) arg0;
        HttpServletResponse response = (HttpServletResponse) arg1;
        String proxyURL =
                "http://" + request.getServerName() + ":" + System.getProperty("gwt.codeserver.port") + request.getRequestURI();
        System.out.println("[Sourcemap proxy filter] proxyURL: " + proxyURL);
        URL url = new URL(proxyURL);
        InputStream is = url.openStream();
        int value;
        while ((value = is.read()) != -1) {
            response.getWriter().write(value);
        }
        is.close();
    }

    @Override
    public void destroy() {
        // noop
    }

}
powtok
  • 11
  • 1
  • 7